{{htmlmetatags>metatag-robots=()
metatag-title=(VAL | ugBASIC User Manual)
metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum)
metatag-description=(Manual page for VAL)
metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png)
metatag-og:title=(VAL | ugBASIC User Manual)
metatag-og:description=(Manual page for VAL)
}}
====== ugBASIC User Manual ======
===== VAL ✓ =====
===== SYNTAX =====
= VAL(string)
==== PURPOSE ====
The ''VAL'' command is a function that allows you to convert a string that represents
a number into a integer numeric value. In other words, it takes a string that contains
numbers and returns the corresponding numeric value.
The ''VAL'' command is very useful when working with user input, because the user
often enters numbers as strings. For example, if we ask the user to enter their age,
the input will be a string. In order to perform calculations with this age, we must
first convert it to a number.
The ''VAL'' function reads the string from left to right and stops at the first
character that is not a number. The ''VAL'' function ignores spaces at the beginning
of the string. If the string does not begin with a number or contains only
non-numeric characters, the ''VAL'' function returns zero.
==== EXAMPLE ====
PRINT VAL("123")
See also the following example files:
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/strings_val_01.bas|strings_val_01.bas]]''
==== ABBREVIATION ====
Va
==== AVAILABLE ON ====
==== SEE ALSO ====
[[STR]]
==== ANY PROBLEM? ====
If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON VAL|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY =====
[[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]