Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Type LogInCredentials
- StrUserName(1 To 10) As String
- intUserPasscode(1 To 10) As Integer
- End Type
- Private udtNewUser As LogInCredentials
- Private udtNewPassword As LogInCredentials
- Private intClickCount As Integer
- Private blnValid
- Private varTempUserPassword As Variant
- Private varTempUserName As Variant
- Private intFoundIndex As Integer
- Private Sub cmdEnter_Click()
- Dim varUserName As Variant
- Dim intPassword As Integer
- 'blnValid = False 'set blnValid to false
- If blnValid = False Then
- varTempUserName = txtUserCode.Text
- Call NameValidation(varTempUserName)
- Else
- varTempUserPassword = txtUserCode.Text
- Call PasswordValidation(varTempUserPassword, intFoundIndex)
- End If
- End Sub
- Private Sub Command1_Click(Index As Integer)
- txtUserCode.Text = txtUserCode.Text & Index
- End Sub
- Private Sub cmdexit_Click()
- End
- End Sub
- Private Sub Form_Load()
- intClickCount = 1
- udtNewUser.StrUserName(1) = "Jack"
- udtNewUser.StrUserName(2) = "Jack"
- udtNewPassword.intUserPasscode(1) = 6688
- udtNewPassword.intUserPasscode(2) = 8899
- blnValid = False
- End Sub
- Private Sub NameValidation(ByVal varUserName As Variant)
- Dim intLoopIndex As Integer
- If varUserName = "" Then
- MsgBox "Please enter your user name in the box"
- txtUserCode.SetFocus
- Else
- For intLoopIndex = 1 To 10
- If varUserName = udtNewUser.StrUserName(intLoopIndex) Then
- MsgBox "Name Found"
- txtUserCode.Text = ""
- Label1.Caption = "Now Please Enter your password"
- intFoundIndex = intLoopIndex
- blnValid = True
- Exit For
- Else
- MsgBox "Wrong Name. Please Try Again"
- txtUserCode.Text = ""
- txtUserCode.SetFocus
- Exit For
- End If
- Next intLoopIndex
- End If
- End Sub
- Private Sub PasswordValidation(ByVal varUserPassword As Variant, ByVal intFoundIndex As Integer)
- If varUserPassword = "" Then
- MsgBox "Wrong password. Please try again"
- ElseIf varUserPassword = udtNewPassword.intUserPasscode(intFoundIndex) Then
- MsgBox "Password accepted."
- ElseIf intClickCount < 3 Then
- MsgBox "Wrong password. Please try again."
- intClickCount = intClickCount + 1
- Else
- MsgBox "You have tried three times without success. The system will now exit."
- End
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement