Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Dim athletes(40) As athlete_login
- Dim admin(2) As admin_login
- Dim confirm As Char
- Dim athlete_counter As Integer = 0
- Dim login_counter As Integer = 0
- Dim menu As Boolean = False
- Dim training_type, user As String
- Dim speed, time, calburned, totalcal, tc As Integer
- Dim login_path As String = "E:\running club\login.csv"
- Dim personal_details_path As String = "E:\running club\personal_details.csv"
- Dim training_record_path As String = "E:\running club\training_record.csv"
- Dim total As String = "E:\running club\training_total.csv"
- Structure admin_login
- Dim username, password As String
- End Structure
- Structure athlete_login
- Dim username, password, name, position As String
- End Structure
- Sub Main()
- login_file()
- login()
- End Sub
- Sub login_file()
- FileOpen(1, login_path, OpenMode.Input)
- Do Until EOF(1)
- Dim line As String = LineInput(1)
- Dim temp() As String = Split(line, ",")
- If temp(2) = "ATHLETE" Then
- athletes(athlete_counter).username = temp(0)
- athletes(athlete_counter).password = temp(1)
- athletes(athlete_counter).name = temp(3)
- athlete_counter += 1
- Else
- admin(login_counter).username = temp(0)
- admin(login_counter).password = temp(1)
- login_counter += 1
- End If
- Loop
- FileClose(1)
- End Sub
- Sub login()
- Console.Clear()
- Console.WriteLine("Username:")
- Dim Username As String = Console.ReadLine
- Console.WriteLine("Password:")
- Dim Password As String = Console.ReadLine
- For i = 0 To athlete_counter - 1
- user = athletes(i).username
- If Username.ToLower = athletes(i).username.ToLower And Password = athletes(i).password Then
- athlete_menu()
- End If
- Next
- For i = 0 To login_counter - 1
- If Username.ToLower = admin(i).username.ToLower And Password = admin(i).password Then
- admin_menu()
- End If
- Next
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("Invalid")
- Console.WriteLine("You will return to login menu in 3 seconds.")
- System.Threading.Thread.Sleep(3000)
- Console.ForegroundColor = ConsoleColor.White
- login()
- End Sub
- Sub admin_menu()
- menu = True
- Console.Clear()
- Console.ForegroundColor = ConsoleColor.Cyan
- Console.WriteLine("WELCOME TO ADMIN'S MENU")
- Console.ForegroundColor = ConsoleColor.White
- Console.WriteLine("1 -Add User")
- Console.WriteLine("2 -Delete User")
- Console.WriteLine("3- View Proggress")
- Console.WriteLine("4 -Log Out")
- Dim pick As Integer = Console.ReadLine()
- Select Case pick
- Case "1"
- add_user()
- Case "2"
- Delete_user()
- Case "3"
- training_progres()
- Case "4"
- Console.WriteLine("You will return to login menu in 3 seconds.")
- System.Threading.Thread.Sleep(3000)
- login()
- End Select
- End Sub
- Sub athlete_menu()
- Console.Clear()
- Console.ForegroundColor = ConsoleColor.Magenta
- Console.WriteLine("WELCOME TO ATHLETE'S MENU")
- Console.ForegroundColor = ConsoleColor.White
- Console.WriteLine("1 -Add Personal Details")
- Console.WriteLine("2 -Edit Personal Details")
- Console.WriteLine("3 -Add Training Record")
- Console.WriteLine("4 -View Training Proggress")
- Console.WriteLine("5 -Log Out")
- Dim pick As Integer = Console.ReadLine()
- Select Case pick
- Case "1"
- Add_Personal_Details()
- Case "2"
- Edit_Personal_Details()
- Case "3"
- Training_record()
- Case "4"
- training_progres()
- Case "5"
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("You will return to login menu in 3 seconds.")
- Console.ForegroundColor = ConsoleColor.White
- System.Threading.Thread.Sleep(3000)
- login()
- End Select
- End Sub
- Sub Training_record()
- Console.Clear()
- Console.WriteLine("What training type you want to add?")
- Console.WriteLine("1 -Running")
- Console.WriteLine("2 -Cycling")
- Console.WriteLine("3 -Swiming")
- Console.WriteLine("4 -Return")
- Dim type As Integer = Console.ReadLine()
- Select Case type
- Case "1"
- running()
- Case "2"
- cycling()
- Case "3"
- swimming()
- Case "4"
- athlete_menu()
- End Select
- End Sub
- Sub running()
- Console.Clear()
- training_type = "Running"
- Console.WriteLine("What speed were you running with,between 5-10(mph)? ")
- speed = Console.ReadLine()
- Console.WriteLine("Please enter the amount of minutes you have been running.")
- time = Console.ReadLine()
- If speed >= 5 And speed < 6 Then
- calburned = 472 / 60 * time
- ElseIf speed >= 6 And speed < 7 Then
- calburned = 590 / 60 * time
- ElseIf speed >= 7 And speed < 8 Then
- calburned = 679 / 60 * time
- ElseIf speed >= 8 And speed < 9 Then
- calburned = 797 / 60 * time
- ElseIf speed >= 9 And speed < 10 Then
- calburned = 885 / 60 * time
- ElseIf speed <= 10 Then
- calburned = 944 / 60 * time
- End If
- save()
- End Sub
- Sub cycling()
- Console.Clear()
- training_type = "Cycling"
- Console.WriteLine("What speed were you cycling with,between (mph)? ")
- speed = Console.ReadLine()
- Console.WriteLine("Please enter the amount of hours you have been cycling for.")
- time = Console.ReadLine()
- If speed > 10 Then
- calburned = 236 * time
- ElseIf speed >= 10 And speed < 12 Then
- calburned = 354 * time
- ElseIf speed >= 12 And speed < 14 Then
- calburned = 472 * time
- ElseIf speed >= 14 And speed < 16 Then
- calburned = 590 * time
- ElseIf speed >= 16 And speed < 20 Then
- calburned = 708 * time
- ElseIf speed < 20 Then
- calburned = 944 * time
- End If
- save()
- End Sub
- Sub swimming()
- Console.Clear()
- training_type = "Swimming"
- Console.WriteLine("Please enter the amount of hours you have been swimming for.")
- time = Console.ReadLine()
- Console.WriteLine("What style were you swimming with? ")
- Console.WriteLine("1 -Freestyle slow or Backstroke")
- Console.WriteLine("2- Freestyle fast or Breaststroke")
- Console.WriteLine("3 -Butterfly")
- confirm = Console.ReadLine()
- Select Case confirm
- Case "1"
- calburned = 413 * time
- save()
- Case "2"
- calburned = 590 * time
- save()
- Case "3"
- calburned = 649 * time
- save()
- End Select
- Console.ReadKey()
- End Sub
- Sub training_progres()
- Console.Clear()
- Dim FullLine As String = ""
- FileOpen(1, training_record_path, OpenMode.Input)
- Do Until EOF(1)
- FullLine = LineInput(1)
- Dim Item() As String = Split(FullLine, ",")
- Console.WriteLine("{0,-10} {1,-10} {2,15}", Item(0), Item(1), Item(2))
- Loop
- Console.WriteLine("Press any key to teturn to menu.")
- Console.ReadKey()
- If menu = True Then
- admin_menu()
- Else
- athlete_menu()
- End If
- End Sub
- Sub Edit_Personal_Details()
- Console.Clear()
- FileOpen(1, personal_details_path, OpenMode.Input)
- Do Until EOF(1)
- Dim line As String = LineInput(1)
- Dim temp() As String = Split(line, ",")
- Dim first As String = temp(1)
- Dim last As String = temp(2)
- Dim age As String = temp(3)
- Dim post As String = temp(4)
- Dim city As String = temp(5)
- Dim house As String = temp(6)
- If temp(0) = user Then
- Console.WriteLine("Please pick the number you want to change")
- Console.WriteLine("1-Firstname: " & first)
- Console.WriteLine("2-Lastname: " & last)
- Console.WriteLine("3-Age: " & age)
- Console.WriteLine("4-Postcode: " & post)
- Console.WriteLine("5-City: " & city)
- Console.WriteLine("6-House Number: " & house)
- confirm = Console.ReadLine()
- Select Case confirm
- Case "1"
- End Select
- End If
- Loop
- FileClose(1)
- End Sub
- Sub Add_Personal_Details()
- Console.Clear()
- Dim FullLine As String = ""
- Dim first As String = ""
- Dim last As String = ""
- Dim age As String = ""
- Dim postcode As String = ""
- Dim city As String = ""
- Dim house_number As String = ""
- Dim total_cal As String = ""
- Console.WriteLine("Please input Your firstname.")
- first = Console.ReadLine()
- Console.WriteLine("Please input Your lastname")
- last = Console.ReadLine()
- Console.WriteLine("Please input Your age")
- age = Console.ReadLine()
- Console.WriteLine("Please input You postcode")
- postcode = Console.ReadLine()
- Console.WriteLine("Please input the city you live in.")
- city = Console.ReadLine()
- Console.WriteLine("Please input Your house number.")
- house_number = Console.ReadLine()
- Console.WriteLine("Are you sure you want to save this input?")
- Console.WriteLine("1 -Yes")
- Console.WriteLine("2 -No, Return to menu")
- confirm = Console.ReadLine()
- Select Case confirm
- Case "1"
- FileOpen(1, personal_details_path, OpenMode.Append)
- FullLine = user & "," & first & "," & last & "," & age & "," & postcode & "," & city & "," & house_number & "," & total_cal
- PrintLine(1, FullLine)
- FileClose(1)
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("Personal Details Saved!")
- Console.WriteLine("Any key will return to menu.")
- Console.ForegroundColor = ConsoleColor.White
- Console.ReadKey()
- athlete_menu()
- Case "2"
- athlete_menu()
- End Select
- End Sub
- Sub Delete_user()
- FileOpen(1, login_path, OpenMode.Input)
- Do Until EOF(1)
- Dim line As String = LineInput(1)
- Dim temp() As String = Split(line, ",")
- athletes(athlete_counter).username = temp(0)
- athletes(athlete_counter).password = temp(1)
- athletes(athlete_counter).name = temp(3)
- athlete_counter += 1
- Loop
- FileClose(1)
- 'Console.WriteLine("Please enter the Username of account You want to delete")
- 'Dim delete As String = Console.ReadLine()
- 'If delete = athletes(athlete_counter).username Then
- ' Console.WriteLine("Are you sure you want to save this input?")
- ' Console.WriteLine("1 -Yes")
- ' Console.WriteLine("2 -No, Return to menu")
- ' confirm = Console.ReadLine()
- ' Select Case confirm
- ' Case "1"
- ' Dim now As String = ""
- ' Dim FullLine As String = ""
- ' FileOpen(2, login_path, OpenMode.Output)
- ' FullLine = now & "," & now & "," & now & "," & now & ","
- ' PrintLine(athletes(athlete_counter).position, FullLine)
- ' FileClose(2)
- ' Console.ForegroundColor = ConsoleColor.Red
- ' Console.WriteLine("USER DELETED!")
- ' Console.WriteLine("Any key will return to menu.")
- ' Console.ForegroundColor = ConsoleColor.White
- ' Console.ReadKey()
- ' admin_menu()
- ' Case "2"
- ' admin_menu()
- ' End Select
- 'Else
- ' Console.WriteLine("Usen not found")
- ' Console.ReadLine()
- 'End If
- End Sub
- Sub add_user()
- Console.Clear()
- Dim FullLine As String = ""
- Dim username As String = ""
- Dim password As String = ""
- Dim type As String = "ATHLETE"
- Dim name As String = ""
- Console.WriteLine("Please input the Username.")
- username = Console.ReadLine()
- Console.WriteLine("Please input the Password.")
- password = Console.ReadLine()
- Console.WriteLine("Please input the Name of Athlete.")
- name = Console.ReadLine()
- Console.WriteLine("Are you sure you want to add this user?")
- Console.WriteLine("1 -Yes")
- Console.WriteLine("2 -No, Return to menu")
- confirm = Console.ReadLine()
- Select Case confirm
- Case "1"
- FileOpen(1, login_path, OpenMode.Append)
- FullLine = username & "," & password & "," & type & "," & name
- PrintLine(1, FullLine)
- FileClose(1)
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("New User Added")
- Console.WriteLine("Any key will return to menu.")
- Console.ForegroundColor = ConsoleColor.White
- Console.ReadKey()
- admin_menu()
- Case "2"
- admin_menu()
- End Select
- End Sub
- Sub save()
- Console.Clear()
- Console.WriteLine("You have burned " & calburned & " calories.")
- Console.WriteLine("Do you want go save this record?")
- Console.WriteLine("1 -Yes")
- Console.WriteLine("2 -No, will go back to manu")
- Dim save As Char = Console.ReadLine
- Select Case save
- Case "1"
- Dim FullLine As String = ""
- FileOpen(1, training_record_path, OpenMode.Append)
- FullLine = user & "," & training_type & "," & calburned
- PrintLine(1, FullLine)
- FileClose(1)
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("Training Saved!")
- Console.WriteLine("Press Any Key To Return To Menu")
- FileOpen(2, total, OpenMode.Input)
- Do Until EOF(2)
- Dim line As String = LineInput(2)
- Dim temp() As String = Split(line, ",")
- Dim username As String = temp(0)
- tc = temp(1)
- Loop
- FileClose(2)
- Dim FullLines As String = ""
- totalcal = tc + calburned
- FileOpen(3, total, OpenMode.Output)
- FullLines = user & "," & totalcal
- PrintLine(3, FullLines)
- FileClose(3)
- Console.ForegroundColor = ConsoleColor.White
- Console.ReadKey()
- athlete_menu()
- Case "2"
- athlete_menu()
- End Select
- Console.ReadKey()
- End Sub
- Sub bullble_sort()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement