I am trying to put in a check for an input box so I can tell if a numeric value was entered. What expression do I write to do this? If it is not numeric I will send an alert then set focus to that field to have then re-enter it.
Printable View
I am trying to put in a check for an input box so I can tell if a numeric value was entered. What expression do I write to do this? If it is not numeric I will send an alert then set focus to that field to have then re-enter it.
The IsNumeric(x) function returns a true/false for if "x" is numeric or not
IsNumeric() works fine.
it obviously returns a boolean value.
IsNull() may also be helpful
Use the ISNUMERIC() function
If not IsNumeric(MyTextBox) then
MsgBox "this value is not numeric"
end if
You can check for Numeric numbers using a function called IsNumeric.
Example:
If IsNumeric(Value) Then
'Do Whatever
Else
ControlName.Setfocus
MsgBox "You have to enter numeric values only."
End If
I knew it was something simple like that but I couldn't remember.
hey hobbes,
if you wanna be really cool, you can call an API that
doesn't even allow you to enter numeric values while inside
the text box.
that way, you don't have to fool with the msgboxen (plural,hehe)