Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Private Type LogInCredentials
  4.  
  5. StrUserName(1 To 10) As String
  6. intUserPasscode(1 To 10) As Integer
  7.  
  8. End Type
  9.  
  10. Private udtNewUser As LogInCredentials
  11. Private udtNewPassword As LogInCredentials
  12.  
  13.  
  14. Private intClickCount As Integer
  15. Private blnValid
  16. Private varTempUserPassword As Variant
  17. Private varTempUserName As Variant
  18.  
  19. Private intFoundIndex As Integer
  20.  
  21. Private Sub cmdEnter_Click()
  22.  
  23. Dim varUserName As Variant
  24.  
  25. Dim intPassword As Integer
  26.  
  27. 'blnValid = False 'set blnValid to false
  28.  
  29. If blnValid = False Then
  30.  
  31. varTempUserName = txtUserCode.Text
  32.  
  33. Call NameValidation(varTempUserName)
  34.  
  35. Else
  36.  
  37. varTempUserPassword = txtUserCode.Text
  38.  
  39. Call PasswordValidation(varTempUserPassword, intFoundIndex)
  40.  
  41. End If
  42.  
  43. End Sub
  44.  
  45.  
  46. Private Sub Command1_Click(Index As Integer)
  47. txtUserCode.Text = txtUserCode.Text & Index
  48. End Sub
  49.  
  50. Private Sub cmdexit_Click()
  51. End
  52. End Sub
  53.  
  54. Private Sub Form_Load()
  55. intClickCount = 1
  56.  
  57. udtNewUser.StrUserName(1) = "Jack"
  58.  
  59. udtNewUser.StrUserName(2) = "Jack"
  60.  
  61.  
  62. udtNewPassword.intUserPasscode(1) = 6688
  63. udtNewPassword.intUserPasscode(2) = 8899
  64.  
  65.  
  66. blnValid = False
  67.  
  68. End Sub
  69.  
  70. Private Sub NameValidation(ByVal varUserName As Variant)
  71.  
  72. Dim intLoopIndex As Integer
  73.  
  74. If varUserName = "" Then
  75.  
  76. MsgBox "Please enter your user name in the box"
  77.  
  78. txtUserCode.SetFocus
  79.  
  80.  
  81. Else
  82.  
  83. For intLoopIndex = 1 To 10
  84.  
  85. If varUserName = udtNewUser.StrUserName(intLoopIndex) Then
  86.  
  87.  
  88. MsgBox "Name Found"
  89.  
  90. txtUserCode.Text = ""
  91.  
  92. Label1.Caption = "Now Please Enter your password"
  93.  
  94. intFoundIndex = intLoopIndex
  95.  
  96.  
  97. blnValid = True
  98.  
  99. Exit For
  100.  
  101.  
  102. Else
  103.  
  104. MsgBox "Wrong Name. Please Try Again"
  105.  
  106. txtUserCode.Text = ""
  107. txtUserCode.SetFocus
  108.  
  109. Exit For
  110.  
  111.  
  112. End If
  113.  
  114. Next intLoopIndex
  115.  
  116. End If
  117.  
  118. End Sub
  119.  
  120. Private Sub PasswordValidation(ByVal varUserPassword As Variant, ByVal intFoundIndex As Integer)
  121.  
  122. If varUserPassword = "" Then
  123.  
  124. MsgBox "Wrong password. Please try again"
  125.  
  126. ElseIf varUserPassword = udtNewPassword.intUserPasscode(intFoundIndex) Then
  127.  
  128.  
  129. MsgBox "Password accepted."
  130.  
  131. ElseIf intClickCount < 3 Then
  132.  
  133. MsgBox "Wrong password. Please try again."
  134. intClickCount = intClickCount + 1
  135.  
  136. Else
  137.  
  138. MsgBox "You have tried three times without success. The system will now exit."
  139. End
  140.  
  141. End If
  142.  
  143. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement