Converts a string containing a representation of a numeric value into a numeric value.
Remarks and Examples
Given a string that contains a represntation of an integer or floating-point number, the VAL function converts it into a numeric value. The returned numeric value could be stored in an integer or floating-point variable, or used in a mathematical expression.
10 A$ = "33.45" 20 A = VAL(A$) 30 PRINT A RUN
Trailing and leading spaces are ignored by VAL:
PRINT VAL(" 25 ")
If VAL is given a string that does not contain a valid representation of a number, VAL will return 0. This includes the case where multiple numeric values may be present in the string:
PRINT VAL("25 45.6 300")
VAL only recognizes period characters (".") as decimal points; "European"-style decimals using commas are not recognized.
To convert a numeric value into a string, use the STR$ function.
Note: Although the current version of ReadyBASIC does not support scientific notation in expressions in program listings, VAL will correctly handle strings containing values expressed in scientific notation:
Full support for scientific notation will be added in a later version of ReadyBASIC.
Copyright 2006-2008, Kevin Matz, All Rights Reserved.