summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorioab <a@ioab.net>2015-11-04 00:49:44 +0300
committerioab <a@ioab.net>2015-11-04 00:49:44 +0300
commit4552c56f03754ac6349c96ab73f794ecf1861254 (patch)
tree7f343bc557648871e885f17f040175e2e6ac774f
parentd92db6ea39723c7778b225de0f27d977bdee0b99 (diff)
[vb/en] remove unnecessary lines. Improve conditions (8 and 9) subs.
-rw-r--r--visualbasic.html.markdown18
1 files changed, 8 insertions, 10 deletions
diff --git a/visualbasic.html.markdown b/visualbasic.html.markdown
index d6d1759d..30d03f77 100644
--- a/visualbasic.html.markdown
+++ b/visualbasic.html.markdown
@@ -222,7 +222,7 @@ Module Module1
'Eight
Private Sub ConditionalStatement()
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.
userName = Console.ReadLine() 'Stores the users name.
If userName = "Adam" Then
@@ -244,30 +244,28 @@ Module Module1
'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, 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("A2. for Fanta")
Console.WriteLine("A3. for Dr. Pepper")
Console.WriteLine("A4. for Diet Coke")
- Console.ReadLine()
+
+ selection = Console.ReadLine() 'Store a selection from the user
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()
+ Console.WriteLine("Sorry, I don't have any " + selection)
End If
+ Console.ReadLine()
End Sub