1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 14:56:54 +02:00

[vb/en] remove unnecessary lines. Improve conditions (8 and 9) subs.

This commit is contained in:
ioab
2015-11-04 00:49:44 +03:00
parent d92db6ea39
commit 4552c56f03

View File

@@ -222,7 +222,7 @@ Module Module1
'Eight 'Eight
Private Sub ConditionalStatement() Private Sub ConditionalStatement()
Console.Title = "Conditional Statements | Learn X in Y Minutes" Console.Title = "Conditional Statements | Learn X in Y Minutes"
Dim userName As String = Console.ReadLine Dim userName As String
Console.WriteLine("Hello, What is your name? ") 'Ask the user their name. Console.WriteLine("Hello, What is your name? ") 'Ask the user their name.
userName = Console.ReadLine() 'Stores the users name. userName = Console.ReadLine() 'Stores the users name.
If userName = "Adam" Then If userName = "Adam" Then
@@ -244,30 +244,28 @@ Module Module1
'When this is the case, more than one if statement would be required. '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. 'An if statement is great for vending machines. Where the user enters a code.
'A1, A2, A3, etc to select an item. 'A1, A2, A3, etc to select an item.
'All choices can be combined into a single if statement. 'All choices can be combined into a single if block.
Dim selection As String = Console.ReadLine 'Value for selection Dim selection As String 'Declare a variable for selection
Console.WriteLine("Please select a product form our lovely vending machine.")
Console.WriteLine("A1. for 7Up") Console.WriteLine("A1. for 7Up")
Console.WriteLine("A2. for Fanta") Console.WriteLine("A2. for Fanta")
Console.WriteLine("A3. for Dr. Pepper") Console.WriteLine("A3. for Dr. Pepper")
Console.WriteLine("A4. for Diet Coke") Console.WriteLine("A4. for Diet Coke")
Console.ReadLine()
selection = Console.ReadLine() 'Store a selection from the user
If selection = "A1" Then If selection = "A1" Then
Console.WriteLine("7up") Console.WriteLine("7up")
Console.ReadLine()
ElseIf selection = "A2" Then ElseIf selection = "A2" Then
Console.WriteLine("fanta") Console.WriteLine("fanta")
Console.ReadLine()
ElseIf selection = "A3" Then ElseIf selection = "A3" Then
Console.WriteLine("dr. pepper") Console.WriteLine("dr. pepper")
Console.ReadLine()
ElseIf selection = "A4" Then ElseIf selection = "A4" Then
Console.WriteLine("diet coke") Console.WriteLine("diet coke")
Console.ReadLine()
Else Else
Console.WriteLine("Please select a product") Console.WriteLine("Sorry, I don't have any " + selection)
Console.ReadLine()
End If End If
Console.ReadLine()
End Sub End Sub