VAL( ) Function

Returns a numeric or currency value from a character expression composed of numbers. You can use VAL( ) to convert the character strings returned by the Visual FoxPro SYS( ) functions to numeric values.

VAL(cExpression)

Parameters

  • cExpression
    Specifies a character expression composed of up to 16 numbers. Rounding occurs if more than 16 numbers are included in cExpression.

    If the first character of cExpression is a dollar sign ($),VAL( ) returns a currency value. In all other situations VAL( ) returns a numeric value.

Return Values

Numeric or Currency data type. VAL( ) returns the numbers in the character expression from left to right until a non-numeric character is encountered. Leading blanks are ignored. VAL( ) returns 0 if the first character of the character expression is not a number, a dollar sign ($), a plus sign (+), or minus sign (-).

Example

CLEAR
STORE '12' TO A
STORE '13' TO B
? VAL(A) + VAL(B)  && Displays 25.00
STORE '1.25E3' TO C
? 2 * VAL(C)  && Displays 2500.00

See Also

SET DECIMALS | STR( ) | SYS( ) Functions Overview