用户登录有问题,麻烦帮忙看一下哪里有问题,谢谢?
warge 2010-03-09 09:56:45 我的用户登录无论输入哪个用户名,程序只认第一条用户的密码,帮忙看看我代码错在哪里,麻烦了
登陆界面代码
Public OK As Boolean
Private Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
Static try_times As Byte
Dim strusername As String
Dim strpassword As String
strusername = txtUserName.Text
strpassword = txtPassword.Text
If strusername = "" Then
MsgBox "请输入用户名", vbOKOnly + vbCritical, "警告"
txtUserName.SetFocus
Exit Sub
End If
If strpassword = "" Then
MsgBox "请输入密码", vbOKOnly + vbCritical, "警告"
txtPassword.SetFocus
Exit Sub
End If
strusername = makestr(strusername)
strpassword = makestr(strpassword)
If myuser.existuser(strusername) = False Then
MsgBox "用户名不存在", vbOKOnly + vbCritical, "警告"
txtUserName = ""
txtUserName.SetFocus
try_times = try_times + 1
If try_times >= 3 Then
MsgBox "对不起,您已经尝试三次进入系统,均不成功,系统将关闭!", vbOKOnly + vbCritical, "警告"
disconnect
OK = False
Me.Hide
Exit Sub
Else
Exit Sub
End If
End If
myuser.getinfo (strusername)
If myuser.strpwd <> strpassword Then
MsgBox "密码错误", vbOKOnly + vbCritical, "警告"
txtPassword.Text = ""
txtPassword.SetFocus
try_times = try_times + 1
If try_times = try_times >= 3 Then
MsgBox "对不起,您已经尝试三次进入系统,均不成功,系统将关闭!", vbOKOnly + vbCritical, "警告"
disconnect
OK = False
Me.Hide
Exit Sub
Else
Exit Sub
End If
End If
curuser.iuserclass = myuser.iuserclass
curuser.strname = myuser.strname
curuser.strpwd = myuser.strpwd
OK = True
Me.Hide
End Sub