Val


Function Val( string expression )


Returns a number, which is the numeric value of string expression.


Syntax a = Val( "10" )


Remarks

Converts the string expression to a floating point value.


Restrictions

The string expression must consist of an optional sign (- only), a string expression of digits with an optional decimal point, and an optional 'E' or 'e' followed by a signed integer.

Leading and trailing blanks in the string expression are ignored.

Thousand separators and currency symbols are not allowed in the string expression.

If the string expression doesn't contain a valid value, a runtime error will occur.


See Also

Str Hex Conversion Functions String Functions


Example Script


NUMBER i

STRING s(20)


FOR i = 0 TO 19

s(i) = STR(i)

NEXT


FOR i = 0 TO 19

PRINT i; " + 1 = "; VAL(s(i)) + 1

NEXT

ERASE(s)


Script Output


0 + 1 = 1

1 + 1 = 2

2 + 1 = 3

3 + 1 = 4

4 + 1 = 5

5 + 1 = 6

6 + 1 = 7

7 + 1 = 8

8 + 1 = 9

9 + 1 = 10

10 + 1 = 11

11 + 1 = 12

12 + 1 = 13

13 + 1 = 14

14 + 1 = 15

15 + 1 = 16

16 + 1 = 17

17 + 1 = 18

18 + 1 = 19

19 + 1 = 20