VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Password Protection With Up To 3 Attemps

by JamesJD (11 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (10 Votes)

This will ask the user to enter a password and if it is incorrect it will give them two more chances (three attempts in total). Please vote and leave comments :)

Inputs
One Command Button name Command1.

Rate Password Protection With Up To 3 Attemps

Private Sub Command1_Click()
  Dim Password As String
  Dim InputPassword As String
  Dim Attempt As Integer
  Password = "Secret"
  Attempt = 0
  Do
    InputPassword = InputBox("Enter password. This is attempt number " & Attempt & ".")
    Attempt = Attempt + 1
  Loop Until (Attempt = 3) Or (InputPassword = Password)
  If InputPassword = Password Then
    MsgBox ("This password is valid!")
  Else
    MsgBox ("This password is invalid!")
  End If
End Sub

Download this snippet    Add to My Saved Code

Password Protection With Up To 3 Attemps Comments

No comments have been posted about Password Protection With Up To 3 Attemps. Why not be the first to post a comment about Password Protection With Up To 3 Attemps.

Post your comment

Subject:
Message:
0/1000 characters