Option Explicit On Imports System.IO Module Module1 Structure Users <VBFixedString(16)> Dim strUsername As String <VBFixedString(16)> Dim strPassword As String Dim charAccountType As Char End Structure Sub Main() 'declares the variables Dim strEnterPassword, strEnterUsername, FileName As String Dim blnCheck, blnUserCheck As Boolean Dim intAttempts, NoOfRecords As Integer Dim arrUserdetails As Users Dim noOfRecords As Integer Dim pos As Integer pos = 0 FileName = "Datastore.dat" FileOpen(1, FileName, OpenMode.Random, , , Len(arrAccount)) noOfRecords = LOF(1) / len(arrAccount) 'initialises the variables strEnterPassword = "" strEnterUsername = "" blnCheck = False intAttempts = 0 blnUserCheck = False Do While Not EOF(1) FileGet(1, arrAccount) Loop Console.WriteLine("Enter your username") strEnterUsername = Console.ReadLine() Do Until blnUserCheck = True Or pos = noOfRecords + 1 If strEnterUsername = arrAccount.strUsername(pos) Then blnUserCheck = True Else pos = pos + 1 End If Loop If pos = noOfRecords + 1 Then Console.WriteLine(strEnterUsername & " " & "is not a valid username") ElseIf blnUsercheck = True Then 'sets up a loop that will finish when the statement becomes true or if it has been attempted 3 times Do Until blnCheck = True Or intAttempts = 3 'asks the user to input their details intAttempts = intAttempts + 1 Console.WriteLine("You have" & " " & 4 - intAttempts & " " & "attempts remaining.") Console.WriteLine("Enter your password") strEnterUsername = Console.ReadLine() 'checks if the statement is true or false, and outputs a relevant message If strEnterPassword = arrUserdetails.strPassword(pos) Then blnCheck = True Console.WriteLine("Access granted") Console.Read() Else Console.WriteLine("Details incorrect, please try again.") Console.Read() End If Loop 'tells the user the attempts have been exceeded If intAttempts = 3 Then Console.WriteLine("You have exceeded the amount of password attempts.") Console.ReadLine() Else Console.WriteLine("Access granted.") Console.ReadLine() End If End If End Sub End Module