Val function

Official Content
This documentation is valid for:

To convert a number in character format into numeric format.



Type Returned:
Numeric N(18.2)

    Must be a Character Expression.


This function converts the numbers of a character expression into a numeric type. It processes the numbers in the character expression from left to right until a non-numeric character is encountered. If the first character of the character expression is not a number, the result of Val function will be 0.


&Result = Val('-123.35')         // Result is -123.35
&Result = Val(STR(123.35, 6, 2)) // Result is 123.35
&Result = Val('ABC')             // Result is 0 (*)
&Result = Val('12A')             // Result is 12 (*)
&WebSesNbr = Val(&SessionId)     // where &WebSesNbr is N(10.0) and &SessionId is C(30)

(*) Converting alphanumerics to numerics is not supported when the method is evaluated in the DBMS (see Server Side Functions/Methods or SAC 42709).


Objects Procedure object, Transaction object, Web Panel object
Languages .NET, Java, Ruby, Visual FoxPro

See also

ToNumeric Method
ToString method
Str function