Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Structure Account
- Dim intYear As Integer
- <VBFixedString(20)> Dim strFirstName As String
- <VBFixedString(20)> Dim strSurname As String
- <VBFixedString(22)> Dim strUsername As String
- <VBFixedString(2)> Dim strAccountclass As String
- <VBFixedString(22)> Dim strPassword As String
- Dim charForm As Char
- End Structure
- Public arrAccount As Account
- Sub Main()
- 'declares the variables
- Dim strEnterPassword, strEnterUsername, FileName As String
- Dim blnpasswordCheck, blnUserCheck As Boolean
- FileName = "C:\Users\David\computing\Datastore.txt"
- FileOpen(1, FileName, OpenMode.Random, , , Len(arraccount))
- 'initialises the variables
- strEnterPassword = ""
- strEnterUsername = ""
- blnpasswordCheck = False
- blnUserCheck = False
- Call fileaccess(FileName)
- Call VerifyUser(strEnterPassword, blnUserCheck, FileName)
- If blnUserCheck = True Then
- Call VerifyPassword(strEnterPassword, blnpasswordCheck)
- End If
- If blnpasswordCheck = True And arrAccount.strAccountclass = "P" Then
- 'open pupil
- ElseIf blnpasswordCheck = True And arrAccount.strAccountclass = "S" Then
- 'open teacher menu
- End If
- FileClose(1)
- End Sub
- Sub fileaccess(ByVal filename)
- Dim noofrecords As Integer
- FileOpen(1, filename, OpenMode.Random, , , Len(arrAccount))
- noofrecords = LOF(1) / Len(arrAccount)
- End Sub
- Function VerifyUser(ByRef strEnterUsername, ByRef blnUserCheck, ByVal FileName)
- Console.WriteLine("Enter your username")
- strEnterUsername = Console.ReadLine()
- Do While Not EOF(1) Or blnUserCheck = True
- FileGet(1, arrAccount)
- If Trim(strEnterUsername) = Trim(arrAccount.strUsername) Then
- Console.WriteLine("Welcome" & " " & arrAccount.strFirstName)
- Console.ReadLine()
- blnUserCheck = True
- Else
- Console.WriteLine(strEnterUsername & " " & "is not a valid username.")
- Console.ReadLine()
- End If
- Loop
- If blnUserCheck = True Then
- End If
- End Function
- Function VerifyPassword(ByRef strEnterPassword, ByRef blnPasswordCheck)
- Dim intattempts As Integer
- intattempts = 0
- Do
- 'asks the user to input their details
- intAttempts = intAttempts + 1
- Console.WriteLine("You have" & " " & 4 - intAttempts & " " & "attempts remaining.")
- Console.WriteLine("Enter your password")
- strEnterPassword = Console.ReadLine()
- If strEnterPassword = Trim(arrAccount.strPassword) Then
- blnPasswordCheck = True
- End If
- 'checks if the statement is true or false, and outputs a relevant message
- Loop Until (blnPasswordCheck = True Or intAttempts = 3)
- End Function
- Sub Output(ByVal blnPasswordCheck)
- 'If blnPasswordCheck = True Then
- ' Console.writeline("Welcome" & " " & trim(arrAccount.strUsername)")
- 'Else
- ' console.writeline("Sorry, you exceeded the amount of password attempts. The password is case sensitive")
- 'End If
- End Sub
- End Module
Add Comment
Please, Sign In to add comment