VAL( string )

VAL converts a string to a decimal number. For example, VAL("10") will return 10. The function parses the string from the left and returns the longest number it can read, stopping at the first non-suitable character it finds.

Incidentally, this function is the opposite of STR , which converts a number to a string.

string can contain negative numbers or hex numbers when preceded by a $.

VAL does only INTEGER interpretation


DIM astring(20) as STRING
astring = "20xa211"
b = VAL(astring)
PRINT astring, b

20xa211   20
Differences from other BASICs

See also