Skip to content

IsNumber ​

The function IsNumber returns True or False depending on whether the input string contains only numeric characters or not.

If this function returns True, then you can safely use a conversion function on it to turn it into a numeric data type. Please refer to Conversion Functions for more detail.

Also refer to IsCurrencyNumber IsCurrencyNumber for a function that checks if the string contains a number in currency format. This function allows currency format symbols like $.

Declaration: Function IsNumber( const S : string) : Boolean

Examples as below.

pascal
Procedure ScriptEvent(var Value:variant);
var CheckVar : boolean;
begin
  CheckVar := IsNumber('abc123');      // returns FALSE
 If CheckVar = TRUE then
    LogInfo('It is a number!')
 else
    LogInfo('It is NOT a number!');

  CheckVar := IsNumber('758');         // returns TRUE
 If CheckVar = TRUE then
    LogInfo('It is a number!')
 else
    LogInfo('It is NOT a number!');

  CheckVar := IsNumber('$523.61');     // returns FALSE
 If CheckVar = TRUE then
    LogInfo('It is a number!')
 else
    LogInfo('It is NOT a number!');
end;