Partilhar via


VAL( ) Function

Returns a numeric value from a character expression composed of numbers.

VAL(cExpression)

Return Values

Numeric

Parameters

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

Remarks

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 isn't a number or a plus sign (+) or minus sign (-).

VAL( ) can be used to convert the character strings returned by the Visual FoxPro SYS( ) functions to numeric values.

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