Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- ' Variable Declaration
- Dim Money_In, Money_Out, PIN, Num_Of_Attempts, Time_Counter As Integer
- Dim User_Input, Space, Central_Alignment, Central_Transaction_Log_Alignment, Central_Title_Alignment, Right_Alignment, Left_Alignment, Another_Service, Central_Text_Alignment As String
- Dim PIN_Attempt As String = String.Empty
- Dim Info As ConsoleKeyInfo
- Dim File_Num, Count, Last_Record As Integer
- Dim File_Name As String
- Dim Account_Details(200, 200), Titles(4) As String
- Dim Balance As Decimal
- Sub Main()
- ' Login System Variables
- PIN = "1234"
- Num_Of_Attempts = 3
- ' Console Formatting
- Console.WindowHeight = Console.LargestWindowHeight - 10
- Console.WindowWidth = Console.LargestWindowWidth - 15
- Console.ForegroundColor = ConsoleColor.DarkYellow
- Console.BackgroundColor = ConsoleColor.DarkBlue
- Console.Clear()
- Space = " "
- Central_Alignment = " "
- Central_Transaction_Log_Alignment = " "
- Central_Title_Alignment = " "
- Central_Text_Alignment = " "
- Right_Alignment = " "
- Left_Alignment = " "
- ' Titles Array
- Titles(0) = "DATE"
- Titles(1) = "TRANSACTION"
- Titles(2) = "MONEY IN"
- Titles(3) = "MONEY OUT"
- Titles(4) = "BALANCE"
- Login:
- ' Login Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Title_Alignment & " /\\\\\\\\\\\ /\\\ /\\\\ /\\\\\\\\\\\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \/////\\\/// \/\\\ \///\\ \/\\\/////////\\\ /\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \/\\\ \/\\\ /\\/ \/\\\ \/\\\ \/\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \/\\\ /\\\\\ /\\\\\\\\\\ \/\\\ \// /\\\\\\\\\\ \/\\\\\\\\\\\\\\ /\\\\\\\\\ /\\/\\\\\\ \/\\\\\\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \/\\\ /\\\///\\\ \/\\\////// \/\\\\\\\\\\ \/\\\////// \/\\\/////////\\\ \////////\\\ \/\\\////\\\ \/\\\////\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \/\\\ /\\\ \//\\\ \/\\\\\\\\\\ \/\\\/////\\\ \/\\\\\\\\\\ \/\\\ \/\\\ /\\\\\\\\\\ \/\\\ \//\\\ \/\\\\\\\\/ ")
- Console.WriteLine(Central_Title_Alignment & " /\\\ \/\\\ \//\\\ /\\\ \////////\\\ \/\\\ \/\\\ \////////\\\ \/\\\ \/\\\ /\\\/////\\\ \/\\\ \/\\\ \/\\\///\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \//\\\\\\\\\ \///\\\\\/ /\\\\\\\\\\ \/\\\ \/\\\ /\\\\\\\\\\ \/\\\\\\\\\\\\\/ \//\\\\\\\\/\\ \/\\\ \/\\\ \/\\\ \///\\\ ")
- Console.WriteLine(Central_Title_Alignment & " \///////// \///// \////////// \/// \/// \////////// \///////////// \////////\// \/// \/// \/// \/// ")
- Console.WriteLine()
- Console.WriteLine()
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- ' Login System
- Console.Write(Central_Alignment & "Please enter your PIN number: ")
- PIN_Attempt = Console.ReadLine()
- ' IF Statement Representing the PIN System
- If PIN_Attempt = PIN Then
- Console.Beep()
- GoTo LoadFile
- End If
- ' Do...Until Loop Checking to See IF the PIN is Correct or Not, and what to do Next
- Do Until PIN_Attempt = PIN
- If PIN_Attempt <> PIN Then
- ' Sends a Beep to The Console
- Console.Beep()
- Console.Beep()
- Num_Of_Attempts -= 1
- MsgBox("Invalid Pin, please try again. Number of attempts remaining: " & Num_Of_Attempts)
- If Num_Of_Attempts = 0 Then
- MsgBox("Too Many Attempts!! Program Will Close!!")
- End
- End If
- GoTo Login
- End If
- Loop
- Console.ReadLine()
- Menu:
- ' Main Menu
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Main Menu ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- ' Menu
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "1. Account Details")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "2. Withdraw")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "3. Deposit")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "4. Overdraft")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "5. Transaction Log")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "6. Current Balance")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "7. Help")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "8. Exit")
- Console.WriteLine()
- Console.Write(Central_Alignment & "Please select your choice: ")
- Console.CursorVisible = False
- User_Input = Console.ReadLine
- ' Select Case Statement that Displays Menu Items
- Select Case User_Input
- Case 1
- GoTo Account_Details
- Case 2
- GoTo Withdraw
- Case 3
- GoTo Deposit
- Case 4
- GoTo Overdraft
- Case 5
- GoTo Transaction_Log
- Case 6
- GoTo Current_Balance
- Case 7
- GoTo Help
- Case 8
- GoTo Exit_System
- Case Else
- Console.Clear()
- Console.Beep()
- ' Main Menu
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Main Menu ")
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "An error has occured, please enter a number between 1 and 8.")
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Press enter to return to the main menu.")
- Console.ReadLine()
- GoTo Menu
- End Select
- Console.ReadLine()
- Account_Details:
- ' Account Details Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "######################")
- Console.WriteLine(Central_Alignment & " Account Details ")
- Console.WriteLine(Central_Alignment & "######################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- ' Menu
- Console.WriteLine(Central_Alignment & "1. Change PIN")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "2. Overdraft")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "3. Back")
- Console.WriteLine()
- Console.Write(Central_Alignment & "Please select your choice: ")
- User_Input = Console.ReadLine()
- ' Select Case Statement For Account Details
- Select Case User_Input
- Case 1
- GoTo Change_PIN
- Case 2
- GoTo Overdraft
- Case 3
- GoTo Menu
- Case Else
- Console.Clear()
- Console.Beep()
- Console.WriteLine()
- ' Main Menu
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "######################")
- Console.WriteLine(Central_Alignment & " Account Details ")
- Console.WriteLine(Central_Alignment & "#######################")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "An error has occured, please enter a number between 1 and 3.")
- Console.ReadLine()
- GoTo Menu
- End Select
- Console.ReadLine()
- Deposit:
- ' Deposit Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "##############")
- Console.WriteLine(Central_Alignment & " Deposit ")
- Console.WriteLine(Central_Alignment & "##############")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.Write(Central_Text_Alignment & "Please Enter Amount you want to Deposit: £")
- Money_In = Console.ReadLine 'Saves the amount the user entered as Money_In
- Balance = Balance + Money_In 'Adds the money the user wants to deposit to the balance
- ' Confirmation message
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Thank you for your deposit, you now have a balance of £" & Balance & ".")
- Console.WriteLine()
- ' File Import
- File_Name = "account.txt"
- File_Num = FreeFile()
- If File_Name <> "" Then
- Try
- Last_Record = Last_Record + 1 ' Increments records in file by 1
- Account_Details(Last_Record, 0) = Today ' Date
- Account_Details(Last_Record, 1) = "CashPoint" ' Transaction
- Account_Details(Last_Record, 2) = Money_In ' Money_In
- Account_Details(Last_Record, 3) = " " ' Money_Out
- Account_Details(Last_Record, 4) = Balance ' Balance
- ' Append details to file
- FileOpen(File_Num, File_Name, OpenMode.Append)
- PrintLine(File_Num, Account_Details(Last_Record, 0)) ' Date
- PrintLine(File_Num, Account_Details(Last_Record, 1)) ' Transaction
- PrintLine(File_Num, Account_Details(Last_Record, 2)) ' Money_In
- PrintLine(File_Num, Account_Details(Last_Record, 3)) ' Money_Out
- PrintLine(File_Num, Account_Details(Last_Record, 4)) ' Balance
- MsgBox("Deposit File Updated", , "File Updated")
- ' Update Current Record
- Catch ex As Exception
- MsgBox("Error Opening File")
- Finally
- FileClose(File_Num)
- End Try
- End If
- Console.WriteLine(Central_Text_Alignment & "Press enter to return to the main menu.")
- Console.ReadLine()
- GoTo Menu
- Withdraw:
- ' Witdraw Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Withdraw ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.WriteLine(Right_Alignment & "================")
- Console.Write(Central_Text_Alignment & "Please Enter Amount to Withdraw: £")
- Money_Out = Console.ReadLine 'Saves the amount of money the user wants to withdraw as Money_Out
- '***Checks if input is multiple of 5***
- If Money_Out Mod 5 <> 0 Then
- MsgBox("Amount Must Be A Multiple Of 5!")
- GoTo Withdraw
- End If
- '***Checks if there is enough balance to withdraw from***
- If Money_Out > 300 Then 'Checks if the user is trying to withdraw more than £300
- MsgBox("Exceeds Daily Amount") 'Displays message box
- GoTo Withdraw 'Goes back to begining of withdraw screen
- End If
- If Money_Out > Balance Then 'Is the user trying to take out more money then is in the balance?
- MsgBox("Insuficient Funds") 'Displays message box if there isn't enough balance
- GoTo Withdraw 'Goes to the Withdraw screen
- End If
- ' Check withdrawal against balance
- If Money_Out <= Balance Then
- Balance = Balance - Money_Out
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "You now have a balance of £" & Balance & ".")
- Console.WriteLine()
- File_Name = "account.txt"
- File_Num = FreeFile()
- If File_Name <> "" Then
- Try
- Last_Record = Last_Record + 1 ' Increments records in file by 1
- Account_Details(Last_Record, 0) = Today ' Date
- Account_Details(Last_Record, 1) = "CashPoint" ' Transaction
- Account_Details(Last_Record, 2) = " " ' Money_In
- Account_Details(Last_Record, 3) = Money_Out ' Money_Out
- Account_Details(Last_Record, 4) = Balance ' Balance
- ' Append details to file
- FileOpen(File_Num, File_Name, OpenMode.Append)
- PrintLine(File_Num, Account_Details(Last_Record, 0)) ' Date
- PrintLine(File_Num, Account_Details(Last_Record, 1)) ' Transaction
- PrintLine(File_Num, Account_Details(Last_Record, 2)) ' Money_In
- PrintLine(File_Num, Account_Details(Last_Record, 3)) ' Money_Out
- PrintLine(File_Num, Account_Details(Last_Record, 4)) ' Balance
- MsgBox("Transaction File Updated", , "File Updated")
- ' Update Current Record
- Catch ex As Exception
- MsgBox("Error Opening File")
- Finally
- FileClose(File_Num)
- End Try
- End If
- Else
- Console.WriteLine("Sorry - Insufficient Funds")
- Console.ReadLine()
- End If
- Console.WriteLine(Central_Text_Alignment & "Press enter to return to the main menu.")
- Console.ReadLine()
- GoTo Menu
- Transaction_Log:
- ' Transaction Log
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "######################")
- Console.WriteLine(Central_Alignment & " Transaction Log ")
- Console.WriteLine(Central_Alignment & "######################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Transaction_Log_Alignment & " " & Titles(0) & " " & Titles(1) & " " & Titles(2) & " " & Titles(3) & " " & Titles(4))
- Console.ForegroundColor = ConsoleColor.Gray
- ' For Loop Displaying Records
- For Count = 0 To Last_Record
- Console.WriteLine(Central_Transaction_Log_Alignment & Account_Details(Count, 0) & Space & Account_Details(Count, 1) & Space & Account_Details(Count, 2) & " " & Account_Details(Count, 3) & " " & Account_Details(Count, 4))
- Next Count
- Console.ForegroundColor = ConsoleColor.DarkYellow
- Console.WriteLine()
- Console.WriteLine(Right_Alignment & "Total Balance £" & Balance)
- Console.ReadLine()
- GoTo Menu
- Current_Balance:
- ' Current Balance
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Balance ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Your Current Balance is: £" & Balance & ".")
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Press enter to return to the main menu.")
- Console.ReadLine()
- GoTo Menu
- Help:
- ' Help Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Help ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Check Account Details")
- Console.WriteLine(Central_Text_Alignment & "===========================")
- Console.WriteLine(Central_Text_Alignment & "If you want to check account details, select option 1 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Make Withdrawal")
- Console.WriteLine(Central_Text_Alignment & "==============")
- Console.WriteLine(Central_Text_Alignment & "If you want to make a withdrawal, select option 2 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Make Deposit")
- Console.WriteLine(Central_Text_Alignment & "============")
- Console.WriteLine(Central_Text_Alignment & "If you want to make a deposit, select option 3 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Apply for Overdraft")
- Console.WriteLine(Central_Text_Alignment & "===================")
- Console.WriteLine(Central_Text_Alignment & "If you want to apply for overdraft, select option 4 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Check Previous Transactions")
- Console.WriteLine(Central_Text_Alignment & "===========================")
- Console.WriteLine(Central_Text_Alignment & "If you want to check previous transactions, select option 5 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Check Balance")
- Console.WriteLine(Central_Text_Alignment & "=============")
- Console.WriteLine(Central_Text_Alignment & "If you want to check you balance, select option 6 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.WriteLine(Central_Text_Alignment & "Exiting System")
- Console.WriteLine(Central_Text_Alignment & "==============")
- Console.WriteLine(Central_Text_Alignment & "If you want to exit the system, select option 8 on the menu screen.")
- Console.WriteLine()
- Console.WriteLine()
- Console.ReadLine()
- GoTo Menu
- Exit_System:
- ' Application Exit Menu
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Exit ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.WriteLine(Right_Alignment & "================")
- Console.WriteLine(Central_Alignment & "Are you sure you want to exit?")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "1. No")
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "2. Yes")
- Console.WriteLine()
- User_Input = Console.ReadLine
- ' Select Case Statement that Displays Menu Items
- Select Case User_Input
- Case 1
- GoTo Menu
- Case 2
- End
- End Select
- Console.ReadLine()
- Change_PIN:
- Num_Of_Attempts = 3
- ' Change PIN Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Change PIN ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.Write(Central_Alignment & "Please enter new PIN: ")
- User_Input = Console.ReadLine
- ' IF Statement Seeing IF User_Input is Not Equal to PIN and IF the length of User_Input is Equal the length of "1234"
- If User_Input <> PIN And User_Input.Length = "1234".Length Then
- PIN = User_Input
- MsgBox("Your PIN has successfuly changed. You will now be returned to the menu.")
- GoTo Menu
- End If
- ' Do Until Loop Seeing whether IF User_Input is Not Equal to PIN
- Do Until User_Input <> PIN
- If User_Input = PIN Then
- Num_Of_Attempts -= 1
- MsgBox("Your new PIN cannot be the same as your current PIN. Please try again. Attempts remaining: " & Num_Of_Attempts)
- If Num_Of_Attempts = 0 Then
- MsgBox("Too many Attempts. Please try again later.")
- GoTo Account_Details
- End If
- GoTo Change_PIN
- End If
- Loop
- ' Do Until Loop with Nested IF Statements
- Do Until User_Input.Length = "1234".Length
- If User_Input.Length <> "1234".Length Then
- Num_Of_Attempts -= 1
- MsgBox("Your new PIN is either too long or too short, please try again. Attempts remaining: " & Num_Of_Attempts)
- If Num_Of_Attempts = 0 Then
- MsgBox("Too many Attempts. Please try again later.")
- GoTo Account_Details
- End If
- GoTo Change_PIN
- End If
- Loop
- Console.ReadLine()
- Overdraft:
- ' Overdraft Screen
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Central_Alignment & "################")
- Console.WriteLine(Central_Alignment & " Overdraft ")
- Console.WriteLine(Central_Alignment & "################")
- ' Date
- Console.WriteLine(Right_Alignment & "Date: " & Today)
- Console.Write(Right_Alignment & "================")
- Console.WriteLine()
- Console.Write(Central_Text_Alignment & "Please enter the amount you wish to overdraft: £")
- User_Input = Console.ReadLine()
- Console.WriteLine()
- Console.Write(Central_Text_Alignment & "Please pay £" & User_Input * 1.5 & " back in 30 days.")
- Console.WriteLine()
- Console.Write(Central_Text_Alignment & "Press enter to return to the main menu.")
- Console.ReadLine()
- LoadFile: ' Procedure to load the file into memory
- File_Name = "account.txt"
- File_Num = FreeFile() ' Set File_Number with Freefile function
- Count = 0 ' Initialise to start at zero
- If File_Name <> "" Then
- Try
- FileOpen(File_Num, File_Name, OpenMode.Input) ' Open file for reading
- Do Until EOF(File_Num)
- Count = Count + 1 ' Increment Count for Array
- Account_Details(Count, 0) = LineInput(File_Num) ' Date
- Account_Details(Count, 1) = LineInput(File_Num) ' Transaction
- Account_Details(Count, 2) = LineInput(File_Num) ' MoneyIn
- Account_Details(Count, 3) = LineInput(File_Num) ' MoneyOut
- Account_Details(Count, 4) = LineInput(File_Num) ' Balance
- Balance = Account_Details(Count, 4) ' Balance
- Loop
- Last_Record = Count ' Store number of last record in the array
- Catch
- MsgBox("Error Opening File")
- Finally
- FileClose(File_Num)
- End Try
- End If
- Last_Record = Count
- 'MsgBox("File Loaded", , Last_Record & " FILES UPDATED")
- GoTo Menu ' Display MainMenu
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement