IsNumeric Function

See AlsoY6VY16              Example2Y9B0BJ>Low

Returns a value indicating whether or not a Variant8PHEAW3 variable can be converted to a numeric data type3GYXY7.

Syntax

IsNumeric(variant)

Remarks

The argument variant can be any Variant expression.  The IsNumeric function returns True if the expression can legally be converted to a number; otherwise, it returns False.  Expressions that can legally be converted to a numeric data type include Variant variables of VarType7A68ZTZ 0 (Empty1L2JEZ4), of any numeric value (VarType 2-6), of VarType 7 (Date), and of VarType 8 (String) if the String can be interpreted as numeric.


See Also

IsDate Function9B784K

IsEmpty Function2K1M5H0

IsNull Function9BAKWR

VarType FunctionXRZH1Y


IsNumeric Function Example

The example evaluates TestVar to determine whether it can legally be converted to a numeric data type and displays an appropriate message.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim TestVar                                 ' Declare variable.

   TestVar = InputBox("Please enter a number, letter, or symbol.")

   If IsNumeric(TestVar) Then                  ' Evaluate variable.

      MsgBox "Entered data is numeric."        ' Message if number.

   Else

      MsgBox "Entered data is not numeric."    ' Message if not.

   End If

End Sub