Try something like
Code:Private Sub Text1_LostFocus() Dim usrnm As String usrnm = TextBox1.Text adoRS.Close adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic If adoRS.Fields("Password").Value = TextBox1.Text And adoRS.Fields("username").Value = "Pengurus" Then pass = True 'if password valid, success Unload Me frmMain.Show Else 'If password invalid intCounter = intCounter + 1 If intCounter = 4 Then MsgBox "You have insert invalid password more then 3", vbCritical, "Warning" intCounter = 0 Unload Me Application.Shutdown Else MsgBox "Please input valid password", vbCritical, "Warning" TextBox1.SetFocus TextBox1.Text = "" End If End If End Sub




Reply With Quote