Retro Rocket OS
BASIC-Powered Operating System
Loading...
Searching...
No Matches
VAL Function
VAL(string-expression)

Converts a string containing a number into an integer value. The string may contain digits 0–9 and an optional leading + or -.


Examples

PRINT VAL("1234")

Produces 1234.

PRINT VAL("-42")

Produces -42.

REM Convert user input
INPUT "Enter a number > " ; n$
x = VAL(n$)
PRINT "You entered "; x
REM Strings that are not numbers
PRINT VAL("hello")

Produces 0.


Notes

  • Returns a 64-bit signed integer.
  • If the string is empty or contains invalid characters, the return value is 0.
  • Only integer values are supported — fractional values are truncated or treated as invalid.
  • For parsing hexadecimal or octal strings, see HEXVAL and OCTVAL.

See also: STR$ · HEXVAL · OCTVAL · RADIX