Mitsubishi QD51 Programming Manual page 83

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

3 LET'S CREATE AND EXECUTE A PROGRAM
3 - 42
(4) Conversion of numbers and characters
The following calculation cannot be performed even if the character string is fully
comprised of numbers.
Example
OK
A$= " 12345"
OK
B=1156
OK
PRINT A$+B
Type mismatch
OK
The VAL function is used when treating a character string comprised of only
numbers as a numeric value. The VAL function converts character strings to
numeric values.
Example
Continued from Example above
A=VAL(A$)
OK
PRINT A+B
13501
OK
Conversely, when handling numeric values as character strings, the STR$
function is used. The STR$ function converts numeric values to character strings.
Example
Continued from Example above
C$=STR$(A+B)
OK
PRINT RIGHT$(C$, 3)
501
OK
Here is a summary of the above points.
VAL
"123"
Characters
STR$
An Illegal Function Call error will be generated if anything other than
numbers, +, -, E, or • are included in the character string that is to
be converted by the VAL function.
123
Numbers
MELSEC-Q
3 - 42

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents