System.Console.WriteLine("hello world")
Doesn't show up for very long.
Dim strChar As String
Console.Write("Enter a character:")
strChar = Console.ReadKey.KeyChar
Console.WriteLine()
Console.WriteLine("You just entered {0},", strChar)
System.Console.Beep(100, 2100)
I modified the next tutorial dealing with entering a line.
Dim i As Integer
For i = 1 To 3
Dim strLine As String
If i = 1 Then
Console.Write("Enter a line of text:")
ElseIf i = 2 Then
Console.WriteLine()
Console.Write("Write another line of text:")
Else
Console.WriteLine()
Console.Write("Write yet another line of text:")
End If
strLine = Console.ReadLine
Console.WriteLine()
Console.WriteLine("You just entered: {0}", strLine)
If i Mod 2 = 0 Then
System.Console.Beep(100, 300)
Else
System.Console.Beep(300, 300)
End If
Next i
And another
Dim strMessage As String
Try
strMessage = Console.ReadLine()
Console.WriteLine("Hello! " + strMessage)
Catch ex As Exception
End Try
System.Console.Beep(200, 400)
And yet another
Dim userInput As String
Console.WriteLine("Enter a source temperature.")
userInput = Console.ReadLine()
Console.WriteLine(userInput)
The only problem is that there aren't any explanations for why we are doing these tutorials, I mean what the point is, and also I'm not entirely sure why we should be using console aps or what they are for.
I added a ucase to the following tutorial as a workaround for case sensitivity
Dim strInput As String
Do
Console.WriteLine("Please enter 'q' to quit...")
strInput = Console.ReadLine()
Console.WriteLine("You typed " & strInput)
Loop While (UCase(strInput) <> "Q")
Console.WriteLine("Quitting now.")
There is another console tutorial dealing with temperatures
Dim intInput As Integer
Console.WriteLine("Enter a temperature...")
intInput = Val(Console.ReadLine())
If intInput > 75 Then
Console.WriteLine("Too hot!")
ElseIf intInput < 55 Then
Console.WriteLine("Too cold!")
Else
Console.WriteLine("Just right!")
End If
End Sub
Here is another tutorial from www.java2s.com, I had a heck of a time getting the uCase to work as it was my personal addition to the code.
Dim strInput As String
While (UCase(strInput) <> "Q")
Console.WriteLine("You typed " & strInput)
Console.WriteLine("Please enter 'q' to quit...")
strInput = Console.ReadLine()
End While
Console.WriteLine("Quitting now.")
I did another tutorial matching patterns and threw in a beep
Dim sInput As String
Dim sPattern As String
Dim sMatch As String
System.Console.Write("please enter a pattern:")
sInput = System.Console.ReadLine()
sPattern = sInput
System.Console.Write("Please enter a string to compare against:")
sInput = System.Console.ReadLine()
sMatch = sInput
If sMatch Like sPattern Then
System.Console.WriteLine(sMatch & " matched with " & sPattern)
Else
System.Console.WriteLine(sMatch & " did not match with " & sPattern)
End If
If sMatch Like sPattern Then
Dim pitch As Integer = 200
For i As Integer = 1 To 4
System.Console.Beep(pitch, 200)
pitch += 100
Next i
Else
Dim pitch As Integer = 500
For i As Integer = 1 To 4
System.Console.Beep(pitch, 200)
pitch = pitch - 100
Next i
End If
No comments:
Post a Comment