Help with an IF routine

M

Mark Wallace

I am writing a rountine which asks user to input a number between 1 and
10.
I know how to say IF the number is 1 then

but how do I get the rountine to start again if the number is invalid?
I cannot remember the bit I add onto the ELSE part of the statment!
 
S

Shell

In response to the post:
I am writing a rountine which asks user to input a number between 1 and
10.
I know how to say IF the number is 1 then

but how do I get the rountine to start again if the number is invalid?
I cannot remember the bit I add onto the ELSE part of the statment!

How about using a "Do While" loop...like this:

Do
intX = CInt(InputBox("Enter a Value From 1 To 10", _
"Take a Guess", "0"))
Loop While intX < 1 or intX > 10

HTH,
Shell
 
H

Helmut Weber

Hi Mark,

try to avoid unwanted input in the first place.

You might use a listbox and offer only valid entries to choose from.
I'd prefer a a listbox on a userform.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top