Skip to main content

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.

Example

DIM a$(20)

a$ = "20xa211"

b =

VAL(a$)

PRINT a$, b

20xa211 20

Differences from other BASICs

  • None from Visual BASIC
  • similar to formatting directives DEC, HEX in PBASIC

See also