VAL
 
Syntax

VAL( string )
Description


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 charater 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 preceeded by a $ or %

VAL does only INTEGER interpretation

Example

DIM a$(20)
a$ = "20xa211"
b = VAL(a$)
PRINT a$, b

20xa211   20

Differences from other BASICs

See also