Table of Contents

Advertisement

142
CHAPTER 6 Command Reference
VAL
(Simple character variable)
Function:
Converts characters in a simple character variable into a numeric value.
Parameter:
Simple character variable: An array character variable cannot be used.
Explanation:
1) Converts characters in a simple character variable into a numeric value
.
2) When the content of a character variable includes +, -, • , E or E , it is
converted into a numeric value as it is.
When A$= "-12.3", VAL(A$)-+-12.3
3) When the content of a character variable starts with a character other than a
numeral, +, -, or • , an error occurs.
When A$= "A45", V AL(A$)-+ error (Error 2)
4) When a character other than a numeral is inserted in the middle, only the part
before this character is converted to a numeric value.
When A$= "78A9", VAL(A$)-+ 78
Example:
1 0
z
$= ,,
1 2 3
11
20 PRINT VAL(Z$)+45
30 END
*If thts program is executed, the numeric values 123 and 45 will be added and
168 will be displayed.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents