For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > January 2006 > Question on Loop Syntax...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Question on Loop Syntax...
Howard

2006-01-09, 10:46 pm

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

Ken Halter

2006-01-09, 10:46 pm

"Howard" <hollywoodhow@gmail.com> wrote in message
news:1135198139.891386.253180@g49g2000cwa.googlegroups.com...
> 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
>


Back in the wrong group? <g> There is no "Console.WriteLine" in VB Classic

You'll want to post that question in a .Net group. They all contain "dotnet"
or "vsnet" in their names.
This and all other groups on the MS server that start with
"microsoft.public.vb" are for VB Classic (VB versions 1-6) and were in
existance long before any .Net products were released. While some of the
code looks the same, they are very different products and require a
different set of groups.

Try one of these:
news://microsoft.public.dotnet.general
news://microsoft.public.dotnet.languages.vb


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


Howard

2006-01-09, 10:46 pm

OOPS! I didn't realize that - you can see how new I am to this.

Thanks.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com