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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation for numeric values 1

Status
Not open for further replies.

Syerston

Programmer
Jun 2, 2001
142
GB
What is the syntax for validating for numeric only values in a text box.

Many thanks
John
 
Hi John!

Try this:

If Isnumeric(YourTextBox) = False Then
Call MsgBox("You must input numbers only")
End If

You might want to trim the entry before testing it.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks Jeff

Fantastic.

Just a quick question. Why would I want to Trim it. John
 
Hi again!

Trimming will get rid of spaces from the start and end of the input string which the user may accidently add. In fact I'm not sure that such spaces will affect the IsNumeric function or not. Some programmers trim input strings just to avoid any possible misunderstandings they may generate in VBA.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top