This code doesn't seem to be working. I don't really know what loop to use to get it too add the information the user puts into the machine to print again.
The aim of this is for the user to either pick:
to print a menu that they have typed in an earlier database. If they haven't typed anything into the database, then it should be blank
Should let the user enter information into the database (What I am mostly struggling with) and do error checking so that it tells them if they have entered a number when they should have entered a letter and
To end the program.
When I do (2) It lets me type but it doesn't recall the information back in the database. Also it needs a number (4) which should return to the main menu. I think this is where the loops come in but I don't know which one to use.
Here is the code:
Structure Cars
Public carmake As String
Public carmodel As String
Public caryear As Integer
Public carlicence As String
End Structure
Module Module1
Sub Main()
Dim userchoice
Console.WriteLine("Choose weather to open the database(1), print it (2) or end (3)")
userchoice = Console.ReadLine()
If userchoice = 1 Then
Dim cardatabase(4) As Cars
Console.WriteLine("This will allow you to view the database.")
Console.WriteLine("Please enter the car make,licence,model and year")
cardatabase(1).carmake = Console.ReadLine()
cardatabase(1).carlicence = Console.ReadLine()
cardatabase(1).carmodel = Console.ReadLine()
cardatabase(1).caryear = Console.ReadLine()
ElseIf userchoice = 2 Then
Console.WriteLine("The database is,")
ElseIf userchoice = 3 Then
Console.WriteLine("Thanks for using this program.")
End If
Console.ReadLine()
End Sub
End Module
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…