Private Sub cmdOK_Click()
'检查正确的密码
If txtPassword.Text = "" Then
MsgBox "Please input password!"
Exit Sub
End If
'先检查是否填好用户名与密码
If txtname.Text = "" Then
MsgBox "Please input username!"
Exit Sub
End If
Dim temp2 As string, temp3 As string, temp4 As String, temp5 As String
temp2 = Trim$((strpassword)
temp3 = Trim$(txtPassword.Text)
temp4 = strusername
temp5 = txtname.Text
'MsgBox strusername
'****************************************
If txtPassword = "1" Then
LoginSucceeded = True
Me.Hide
frmmain.Show
Exit Sub
'超级用户登录
End If
If temp4 = temp5 Then '用户名正确
MsgBox " username=" & temp4
Else
MsgBox "用户名错误,请重试!"
Exit Sub
End If
If temp2 = temp3 Then '如果密码正确
MsgBox txtPassword
LoginSucceeded = True
frmmain.Show
Me.Hide
Exit Sub
Else
MsgBox "密码错误,请重试!", , "登录"
txtname.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
If Right(App.Path, 1) = "\" Then
temp1 = ReadIni(App.Path & "user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "user.ini", "user", "password", strpassword)
Else
temp1 = ReadIni(App.Path & "\user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "\user.ini", "user", "password", strpassword)
End If
End Sub
注:ReadIni为在公用模块中的读ini文件的函数.
这一段程序除了可以用超级用户登录外,怎样都无法进入,请各位帮忙!
'检查正确的密码
If txtPassword.Text = "" Then
MsgBox "Please input password!"
Exit Sub
End If
'先检查是否填好用户名与密码
If txtname.Text = "" Then
MsgBox "Please input username!"
Exit Sub
End If
Dim temp2 As string, temp3 As string, temp4 As String, temp5 As String
temp2 = Trim$((strpassword)
temp3 = Trim$(txtPassword.Text)
temp4 = strusername
temp5 = txtname.Text
'MsgBox strusername
'****************************************
If txtPassword = "1" Then
LoginSucceeded = True
Me.Hide
frmmain.Show
Exit Sub
'超级用户登录
End If
If temp4 = temp5 Then '用户名正确
MsgBox " username=" & temp4
Else
MsgBox "用户名错误,请重试!"
Exit Sub
End If
If temp2 = temp3 Then '如果密码正确
MsgBox txtPassword
LoginSucceeded = True
frmmain.Show
Me.Hide
Exit Sub
Else
MsgBox "密码错误,请重试!", , "登录"
txtname.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
If Right(App.Path, 1) = "\" Then
temp1 = ReadIni(App.Path & "user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "user.ini", "user", "password", strpassword)
Else
temp1 = ReadIni(App.Path & "\user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "\user.ini", "user", "password", strpassword)
End If
End Sub
注:ReadIni为在公用模块中的读ini文件的函数.
这一段程序除了可以用超级用户登录外,怎样都无法进入,请各位帮忙!
检测一下ReadIni函数获取的strusername及strpassword 的值
是否同ini文件中设置的一致
Dim temp1 As Long, temp2 As Long '定义读取配置文件的结果
Dim temp3 As String, temp4 As String, temp5 As String, temp6 As String
'四个临时变量分别储存取出和输入的密码与用户名
但是完全改了也不行啊......
改正的代码如下:
Dim temp1 As Long, temp2 As Long '定义读取配置文件的结果
Dim temp3 As String, temp4 As String, temp5 As String, temp6 As String
'四个临时变量分别储存取出和输入的密码与用户名
Private Sub cmdOK_Click()
'检查正确的密码
If txtPassword.Text = "" Then
MsgBox "Please input password!"
Exit Sub
End If
'先检查是否填好用户名与密码
If txtname.Text = "" Then
MsgBox "Please input username!"
Exit Sub
End If
temp3 = Trim$(strpassword)
temp4 = Trim$(txtPassword.Text)
temp5 = strusername
temp6 = txtname.Text
'****************************************
If txtPassword = "1" Then
LoginSucceeded = True
Me.Hide
frmmain.Show
Exit Sub
'超级用户登录
End IfIf temp5 = temp6 Then '用户名正确
MsgBox " username=" & temp4
Else
MsgBox "用户名错误,请重试!"
Exit Sub
End If
If temp3 = temp4 Then '如果密码正确
MsgBox txtPassword
LoginSucceeded = True
frmmain.Show
Me.Hide
Exit Sub
ElseMsgBox "密码错误,请重试!", , "登录"
txtname.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
If Right(App.Path, 1) = "\" Then
temp1 = ReadIni(App.Path & "user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "user.ini", "user", "password", strpassword)Else
temp1 = ReadIni(App.Path & "\user.ini", "user", "name", strusername)
temp2 = ReadIni(App.Path & "\user.ini", "user", "password", strpassword)End If
end sub
Dim temp2 As string, temp3 As string, temp4 As String, temp5 As String应该是:
Dim temp2, temp3, temp4, temp5 As String
或
Dim temp2 As string
Dim temp3 As string
Dim temp4 As String
Dim temp5 As String验证密码不需要 Trim()程序似乎写复杂了
Dim temp3 As string
Dim temp4 As string
Dim temp5 As String
Dim temp6 As String
也改过了,应该和这个无关的