Advertisement
Guest User

Untitled

a guest
Dec 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. Sub Userlogin(Password, ExitApplication)
  2.  
  3. Dim Confirm
  4. Dim PasswordLength As Integer
  5.  
  6. ' Password System
  7. If Password = "" Then
  8.  
  9. ' Loop until Password is correct.
  10. Do While Password = ""
  11. Password = InputBox("Enter your Password:", "Login")
  12. PasswordLength = Len(Password)
  13.  
  14. ' Asks the user if they want to close the application.
  15. If Password = "" Then
  16. Confirm = MsgBox("Are you sure you want to close this application?", vbYesNo, "Confirm")
  17. End If
  18.  
  19. If Confirm = vbYes Then
  20. ExitApplication = True
  21. Exit Do
  22. Exit Sub
  23. End If
  24.  
  25. If Confirm = vbNo Then
  26. Password = ""
  27. PasswordLength = 8
  28. Confirm = ""
  29. End If
  30.  
  31. ' Checks if the Password is 8 characters.
  32. If Not PasswordLength = 8 Then
  33. MsgBox "The Password must be 8 characters long." & vbNewLine & vbNewLine & "Please Try again.", vbCritical, "Password Incorrect"
  34. Password = ""
  35. End If
  36.  
  37. Loop
  38.  
  39. End If
  40.  
  41. End Sub
  42.  
  43. Sub MainSub()
  44.  
  45. ' Standard Dim's
  46. Dim Username As String
  47. Dim Password As String
  48.  
  49. Dim ExitApplication As Boolean
  50.  
  51. '_______________________________________________________________________________
  52.  
  53. ' Set Values
  54.  
  55. ExitApplication = False
  56. Username = CreateObject("WScript.Network").Username
  57.  
  58. '_______________________________________________________________________________
  59.  
  60. Call Userlogin(Password, ExitApplication)
  61. If ExitApplication = True Then
  62. Exit Sub
  63. End If
  64.  
  65. End Sub
  66.  
  67. Function Userlogin(Password, ExitApplication) As Boolean
  68.  
  69. ' Loop until Password is correct.
  70. Do While Password = ""
  71.  
  72. Call UserLogin(Password, ExitApplication)
  73.  
  74. UserLogin Password, ExitApplication
  75.  
  76. ?StrPtr(""), StrPtr(vbNullString)
  77. 456810912 0
  78.  
  79. ?StrPtr(""), StrPtr(vbNullString)
  80. 458095304 0
  81. 458097512 0
  82. 167896456 0
  83. 241904984 0
  84. 456810912 0
  85.  
  86. If Confirm = vbYes Then
  87. ExitApplication = True
  88. Exit Do
  89. Exit Sub
  90. End If
  91.  
  92. If Confirm = vbNo Then
  93. Password = ""
  94. PasswordLength = 8
  95. Confirm = ""
  96. End If
  97.  
  98. If Confirm = vbYes Then
  99. '...
  100. Else
  101. '...
  102. End If
  103.  
  104. Const RequiredLength As Integer = 8
  105.  
  106. If Len(Password) <> RequiredLength Then
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement