I doing some VB practice projects and one of them is to design a simple Login form with a Validate button, to see if password is correct, and if so exit sub and if password is not correct let the user know they only have 3 tries left.
Here's where iam having trouble, I get the MsgBox to display when the wrong password was entered to tell them they have 3 tries left but it won't allow me to re-enter a password. I have to click the Retry button all the while that it counts down to o tries left then I can re-enter a password.
My question is, once the first MsgBox is displayed telling them they have 3 tries left and the Retry button is click, how do I get to re-enter the password attempt after the first attempt.
Heres some of my code:
**********************************************
Private Sub cmdExit_Click()
End
End Sub
*************************************************
Private Sub cmdValid_Click()
Dim Response As Integer
Dim attempts As Long
attempts = 3
Do While attempts > 0
If txtPassword.Text = txtPassword.Tag Then
MsgBox "You've Passed security !", vbOKOnly + vbExclamation, "Access Granted"
Call cmdExit_Click
Exit Do
Else
Response = MsgBox("Incorrect Password You Have " & attempts & " Tries left ", vbRetryCancel + vbCritical, "access Denied")
If Response = vbRetry And attempts > 0 Then
attempts = attempts - 1
txtPassword.SetFocus
txtPassword.Text = ""
txtPassword.SelStart = 0
Else
End
End If
End If
Loop
End Sub
**************************************
Private Sub Form_Activate()
txtPassword.SetFocus
End Sub
**********************************
PS: I hope I have explained myself clearly and thank you in advance if you can show me the correct way to do this."
Here's where iam having trouble, I get the MsgBox to display when the wrong password was entered to tell them they have 3 tries left but it won't allow me to re-enter a password. I have to click the Retry button all the while that it counts down to o tries left then I can re-enter a password.
My question is, once the first MsgBox is displayed telling them they have 3 tries left and the Retry button is click, how do I get to re-enter the password attempt after the first attempt.
Heres some of my code:
**********************************************
Private Sub cmdExit_Click()
End
End Sub
*************************************************
Private Sub cmdValid_Click()
Dim Response As Integer
Dim attempts As Long
attempts = 3
Do While attempts > 0
If txtPassword.Text = txtPassword.Tag Then
MsgBox "You've Passed security !", vbOKOnly + vbExclamation, "Access Granted"
Call cmdExit_Click
Exit Do
Else
Response = MsgBox("Incorrect Password You Have " & attempts & " Tries left ", vbRetryCancel + vbCritical, "access Denied")
If Response = vbRetry And attempts > 0 Then
attempts = attempts - 1
txtPassword.SetFocus
txtPassword.Text = ""
txtPassword.SelStart = 0
Else
End
End If
End If
Loop
End Sub
**************************************
Private Sub Form_Activate()
txtPassword.SetFocus
End Sub
**********************************
PS: I hope I have explained myself clearly and thank you in advance if you can show me the correct way to do this."