Can someone tell me why this code will not give me three tries
at entering the password. It will only give me one try and then will close.
Private Sub CommandButton1_Click()
Dim myTries As Integer
Dim strPass As String
strPass = TextBox1.Text
Do Until iTries = 3
If strPass = "password" Then
MsgBox "Password Accepted"
Sheets("Main").Visible = True
Unload Me
End
End If
MsgBox "Incorrect Password"
myTries =myiTries + 1
TextBox1.SetFocus
Exit Do
Loop
If myTries = 3 Then Unload Me
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub
Thanks in advance
at entering the password. It will only give me one try and then will close.
Private Sub CommandButton1_Click()
Dim myTries As Integer
Dim strPass As String
strPass = TextBox1.Text
Do Until iTries = 3
If strPass = "password" Then
MsgBox "Password Accepted"
Sheets("Main").Visible = True
Unload Me
End
End If
MsgBox "Incorrect Password"
myTries =myiTries + 1
TextBox1.SetFocus
Exit Do
Loop
If myTries = 3 Then Unload Me
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub
Thanks in advance