H
Howard
Ok, I'm back. I have another question (probably an easy one, even to
non-experts). I was inspired to expand this little program (thanks to
all of your help). If I was using the following code to create a game
that prompts the user to guess a number from 1-100, and wanted to have
the console write a message Console.WriteLine("Invalid Entry") when the
user types in character(s) that are non-numerical - What would the
syntax be for this? Here's the code (which works great) but without
that new part.
Module Module1
Sub Main()
Const Value As Integer = 27
Dim Number As Integer
Console.WriteLine("Pick a number from 1 to 100")
Number = Integer.Parse(Console.ReadLine())
While Number <> Value
If Number < Value Then
Console.WriteLine("Higher")
Else
Console.WriteLine("Lower")
End If
Number = Integer.Parse(Console.ReadLine())
End While
Console.WriteLine("Correct!")
End Sub
End Module
Thank you,
Howard
non-experts). I was inspired to expand this little program (thanks to
all of your help). If I was using the following code to create a game
that prompts the user to guess a number from 1-100, and wanted to have
the console write a message Console.WriteLine("Invalid Entry") when the
user types in character(s) that are non-numerical - What would the
syntax be for this? Here's the code (which works great) but without
that new part.
Module Module1
Sub Main()
Const Value As Integer = 27
Dim Number As Integer
Console.WriteLine("Pick a number from 1 to 100")
Number = Integer.Parse(Console.ReadLine())
While Number <> Value
If Number < Value Then
Console.WriteLine("Higher")
Else
Console.WriteLine("Lower")
End If
Number = Integer.Parse(Console.ReadLine())
End While
Console.WriteLine("Correct!")
End Sub
End Module
Thank you,
Howard