Password Expiry - 3 Strikes Then Out

niailmar

New member
Joined
Apr 4, 2012
Messages
30
Reaction score
0
Points
0
Hello,

I need an expert to solve my problem.

I have login userform, which when user key in wrong password (3 times in a rows), a message will appear and close login userform.

Here the code of enter button:

Code:
[/COLOR][LEFT][COLOR=#333333]Private Sub EnterPassword_Click()[/COLOR][/LEFT]

Dim password As StringDim x As Integerpassword = PasswordInput.TextIf password = WorksheetFunction.VLookup(UserList.Value, Range("Users_List"), 2, 0) ThenMsgBox "Password Accepted"Unload MeWorksheets("PCList").Visible = xlSheetVisibleSheets("PCList").SelectWorksheets("Main Page").Visible = xlSheetVeryHiddenActiveSheet.Range("$A$9:$K$1048576").AutoFilter Field:=11Worksheets("Blank").Visible = xlSheetVeryHiddenElse        For x = 1 To 3If x < 3 ThenMsgBox "Unsuccessfull!"Next x    ElseIf x = 3 ThenMsgBox "Sorry, 3 strikes you're out.", 16, "Cannot continue; incorrect password not given."End IfExit SubEnd If   [LEFT][COLOR=#333333]End Sub[/COLOR][/LEFT][COLOR=#333333]

I attach an interface of login form for your references.
I appreciate your help on this.

Thanks a lot. http://www.excelforum.com/attachment.php?attachmentid=169054&d=1342692981


 
Option Explicit
Public x As Integer


Private Sub loginUserForm_Initialize()
x = 1
enterPassword.Caption = "Enter Password, " & x
End Sub


Private Sub enterPassword_Click()


Dim password As String
password = PasswordInput.Text
If password = WorksheetFunction.VLookup(UserList.Value, Range("Users_List"), 2, 0) Then
MsgBox "Password Accepted"
Unload Me
Worksheets("PCList").Visible = xlSheetVisible
Sheets("PCList").Select
Worksheets("Main Page").Visible = xlSheetVeryHidden
ActiveSheet.Range("$A$9:$K$1048576").AutoFilter Field:=11
Worksheets("Blank").Visible = xlSheetVeryHidden
Else:
If x < 3 Then
MsgBox "Unsuccessfull" & "try number " & x
x = x + 1
enterPassword.Caption = "Enter Password, " & x
PasswordInput.Text = ""
ElseIf x = 3 Then
MsgBox "Sorry, 3 strikes you're out.", 16, "Cannot continue; incorrect password not given."
Me.Hide
Unload Me
End If
Exit Sub
End If
End Sub
 
Back
Top