Guest User

Untitled

a guest
Jun 18th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. Module Module1
  2.  
  3. Structure Account
  4. Dim intYear As Integer
  5. <VBFixedString(20)> Dim strFirstName As String
  6. <VBFixedString(20)> Dim strSurname As String
  7. <VBFixedString(22)> Dim strUsername As String
  8. <VBFixedString(2)> Dim strAccountclass As String
  9. <VBFixedString(22)> Dim strPassword As String
  10. Dim charForm As Char
  11.  
  12. End Structure
  13. Public arrAccount As Account
  14. Sub Main()
  15.  
  16.  
  17. 'declares the variables
  18. Dim strEnterPassword, strEnterUsername, FileName As String
  19. Dim blnpasswordCheck, blnUserCheck As Boolean
  20.  
  21. FileName = "C:\Users\David\computing\Datastore.txt"
  22. FileOpen(1, FileName, OpenMode.Random, , , Len(arraccount))
  23.  
  24. 'initialises the variables
  25. strEnterPassword = ""
  26. strEnterUsername = ""
  27. blnpasswordCheck = False
  28. blnUserCheck = False
  29.  
  30. Call fileaccess(FileName)
  31.  
  32. Call VerifyUser(strEnterPassword, blnUserCheck, FileName)
  33. If blnUserCheck = True Then
  34. Call VerifyPassword(strEnterPassword, blnpasswordCheck)
  35. End If
  36.  
  37. If blnpasswordCheck = True And arrAccount.strAccountclass = "P" Then
  38. 'open pupil
  39. ElseIf blnpasswordCheck = True And arrAccount.strAccountclass = "S" Then
  40. 'open teacher menu
  41.  
  42. End If
  43. FileClose(1)
  44. End Sub
  45.  
  46. Sub fileaccess(ByVal filename)
  47. Dim noofrecords As Integer
  48. FileOpen(1, filename, OpenMode.Random, , , Len(arrAccount))
  49. noofrecords = LOF(1) / Len(arrAccount)
  50.  
  51. End Sub
  52.  
  53. Function VerifyUser(ByRef strEnterUsername, ByRef blnUserCheck, ByVal FileName)
  54. Console.WriteLine("Enter your username")
  55. strEnterUsername = Console.ReadLine()
  56. Do While Not EOF(1) Or blnUserCheck = True
  57. FileGet(1, arrAccount)
  58. If Trim(strEnterUsername) = Trim(arrAccount.strUsername) Then
  59. Console.WriteLine("Welcome" & " " & arrAccount.strFirstName)
  60. Console.ReadLine()
  61. blnUserCheck = True
  62. Else
  63. Console.WriteLine(strEnterUsername & " " & "is not a valid username.")
  64. Console.ReadLine()
  65. End If
  66. Loop
  67. If blnUserCheck = True Then
  68.  
  69. End If
  70. End Function
  71. Function VerifyPassword(ByRef strEnterPassword, ByRef blnPasswordCheck)
  72. Dim intattempts As Integer
  73. intattempts = 0
  74. Do
  75. 'asks the user to input their details
  76. intAttempts = intAttempts + 1
  77. Console.WriteLine("You have" & " " & 4 - intAttempts & " " & "attempts remaining.")
  78. Console.WriteLine("Enter your password")
  79. strEnterPassword = Console.ReadLine()
  80.  
  81. If strEnterPassword = Trim(arrAccount.strPassword) Then
  82. blnPasswordCheck = True
  83. End If
  84.  
  85. 'checks if the statement is true or false, and outputs a relevant message
  86. Loop Until (blnPasswordCheck = True Or intAttempts = 3)
  87. End Function
  88. Sub Output(ByVal blnPasswordCheck)
  89. 'If blnPasswordCheck = True Then
  90. ' Console.writeline("Welcome" & " " & trim(arrAccount.strUsername)")
  91. 'Else
  92. ' console.writeline("Sorry, you exceeded the amount of password attempts. The password is case sensitive")
  93. 'End If
  94. End Sub
  95. End Module
Add Comment
Please, Sign In to add comment