'Ask the question, does the user wish to continue? Unfortunately it
'is case sensitive.
Console.Write("Would you like to continue? (yes / no)")
'The program grabs the variable and prints and starts again.
answer = Console.ReadLine
'The command for the variable to work would be in this case "yes"
Loop While answer = "yes"
End Sub
'Seven
Private Sub UsingForLoops()
'Sometimes the program only needs to run once.
'In this program we'll be counting down from 10.
Console.Title = "Using For Loops | Learn X in Y Minutes"
'Declare Variable and what number it should count down in Step -1,
'Step -2, Step -3 ect.
For i As Integer = 10 To 0 Step -1
Console.WriteLine(i.ToString) 'Print the value of the counter
Next i 'Calculate new value
Console.WriteLine("Start") 'Lets start the program baby!!
Console.ReadLine() 'POW!! - Perhaps I got a little excited then :)
End Sub
'Eight
Private Sub ConditionalStatement()
Console.Title = "Conditional Statements | Learn X in Y Minutes"
Dim userName As String = Console.ReadLine
Console.WriteLine("Hello, What is your name? ") 'Ask the user their name.
userName = Console.ReadLine() 'Stores the users name.
If userName = "Adam" Then
Console.WriteLine("Hello Adam")
Console.WriteLine("Thanks for creating this useful site")
Console.ReadLine()
Else
Console.WriteLine("Hello " + userName)
Console.WriteLine("Have you checked out www.learnxinyminutes.com")
Console.ReadLine() 'Ends and prints the above statement.
End If
End Sub
'Nine
Private Sub IfElseStatement()
Console.Title = "If / Else Statement | Learn X in Y Minutes"
'Sometimes its important to consider more than two alternatives.
'Sometimes there are a good few others.
'When this is the case, more than one if statement would be required.
'An if statement is great for vending machines. Where the user enters a code.
'A1, A2, A3, ect to select an item.
'All choices can be combined into a single if statement.
Dim selection As String = Console.ReadLine 'Value for selection
Console.WriteLine("A1. for 7Up")
Console.WriteLine("A2. for Fanta")
Console.WriteLine("A3. for Dr. Pepper")
Console.WriteLine("A4. for Diet Coke")
Console.ReadLine()
If selection = "A1" Then
Console.WriteLine("7up")
Console.ReadLine()
ElseIf selection = "A2" Then
Console.WriteLine("fanta")
Console.ReadLine()
ElseIf selection = "A3" Then
Console.WriteLine("dr. pepper")
Console.ReadLine()
ElseIf selection = "A4" Then
Console.WriteLine("diet coke")
Console.ReadLine()
Else
Console.WriteLine("Please select a product")
Console.ReadLine()
End If
End Sub
End Module
```
## References
I learnt Visual Basic in the console application. It allowed me to understand the principles of computer programming to go on to learn other programming languages easily.
I created a more indepth <ahref="http://www.vbbootcamp.co.uk/"Title="Visual Basic Tutorial">Visual Basic tutorial</a> for those who would like to learn more.
The entire syntax is valid. Copy the and paste in to the Visual Basic compiler and run (F5) the program.