Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21842

After 5 attempts have the program exit

$
0
0
I am very new to programming and i need very simple instructions on how to finish this program thank you :confused:

I have to create a password program and i've done that but now i have to make it so after 5 failed attempts. I tried to do this but i can't do it properly, this is what i have. Again please show me what to change in the code and how to do it, i haven't been coding for very long so i get lost easily. Thanks again :)

Private Sub cmdOK_Click()

Const secretPassword As Integer = 1234

Dim guess As Integer
Dim attempt As Integer

guess = Val(txtPassword.Text)

If guess = secretPassword Then
MsgBox ("Password Accepted")

Else
txtCheck = ("Incorrect Password-Please try again!")
End If

Do
attempt 1
If guess < secretPassword Then
MsgBox "test"
End If
Loop Until attempt = 5

If attempt = 5 Then
MsgBox ("Please Contact your administrator")
End If

If txtPassword.Text = "1234" Then
Form2.Show
End If

End Sub

Viewing all articles
Browse latest Browse all 21842

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>