inputbox function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there!

I wish to validate the data provided by user thru a inputbox whether the
user has put an integer value n if not to give a message to the user that
only integer values should b typed

Thanks in advance

bins
 
Something like this should work:

Dim varInput As Variant

varInput = InputBox("Give me a number...")
Do While Int(Val(varInput)) <> Val(varInput) _
Or Len(varInput) > 0
MsgBox "That's not an integer..."
varInput = InputBox("Give me a number...")
Loop

This will keep prompting them until they type just an integer. (It also
gives them the option of cancelling or hitting Enter if they want to quit)
 
Back
Top