## STR$() and VAL()
Up to now, we've been using string variables to hold strings
and number variables to hold numbers. What if we really need to
do some math with numbers that are in a string variable? Or maybe
we need to get some numbers into a string variable somehow. QBASIC
provides the STR$() and VAL() functions to help us out.
STR$() will let us convert from a number to a string. Like this:
A = 25 ' A can only hold numbers PRINT A B$ = STR$(A) ' Convert A to a string, store in B$ PRINT B$
VAL() will let us convert from a string to a number. Like this:
A$ = "25" ' Can't do any math with a string variable PRINT A$ B = VAL(A$) ' Convert A$ to a number, store in B PRINT B
## Converting Numbers
Need to cover CINT(), FIX(), INT(), CDBL(), CSNG(), CLNG()
Source: http://jpsor.ucoz.com |