Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping User Inputs in a InputBox

Status
Not open for further replies.

Joeb1

Technical User
Nov 13, 2000
4
US
I want to make sure that users only enter numbers in a input box. What is an easy way to do this? Or even if I have to look for a range of 1 to 50.

I tried an IF statement but I can't figure out how to set a range of numbers with the statement.

Thanks
 
This seems to work


Dim x As String
Do While IsNumeric(x) = False
x = InputBox("Enter Something")
Loop



David Paulson


 
Thanks,

I think I can get that to work.
 
Do you have to use an inputbox?

You can use a textbox, and validate the input in the keypress event:

[tt]
If KeyAscii < Asc(&quot;0&quot;) Or KeyAscii > Asc(&quot;9&quot;) Then
KeyAscii = 0
Exit Sub
End If
[/tt]

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top