请大家帮忙看下代码有什么错误或者多余的地方,谢谢了
Dim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.Recordset
Dim Str_text As String
Private Sub Command1_Click()
On Error Resume Next
Static i As Integer '记数器
Static L As Integer '记数器
Dim Str_name As String
Dim Str_password As String
Dim Str_username As String
Dim Str_userpassword As String
Dim Remainday As Long
Str_name = txt_name.Text
Str_password = txt_password.Text
Set Mydb = ExeCutesql("select user from user1 where user='" & Str_name & "'", Str_text)
If Mydb.EOF Then
MsgBox "你输入的用户名不存在,请重新输入!", vbOKOnly + 32, "注意"
L = L + 1
txt_name.SetFocus
If L = 5 Then
MsgBox "你已经多次输入错误的用户名,请查证后重新登陆!", vbOKOnly + 48, "注意"
End
End If
Exit Sub
Else
Set Mydb1 = ExeCutesql("select user,pass from user1 where user='" & Str_name & "'", Str_text)
Str_username = Trim(Mydb1.Fields(0))
Str_userpassword = Trim(Mydb1.Fields(1))
If Trim(Str_password) = Str_userpassword Then
frm_main.Show
Mydb.Close
Mydb1.Close
Set Mydb = Nothing
Set Mydb1 = Nothing
Unload Me
Else
MsgBox "你输入的密码错误,请重新输入!", vbOKOnly + 32, "注意"
i = i + 1
txt_password.SetFocus
If i = 3 Then
MsgBox "你输入的密码三次都不正确,本系统将关闭!", vbOKOnly + 48, "注意"
End
End If
Exit Sub
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub txt_name_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then txt_password.SetFocus
End Sub
Private Sub txt_password_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1.SetFocus
End Sub
Private Sub txt_name_LostFocus()
Cname = txt_name.Text
End Sub