Basic does type conversions when the resulting value will "fit", but may report "TYPE MISMATCH" when presented with a conversion it thinks might not fit. It is best to match the type or do explicit conversions.
VAL | converts its string argument to a number |
---|---|
STR | converts its numeric argument to a string |
Variables of a specific type are declared by
DIM variable AS typeMost types may be forced by appending the appropriate trailing character (called a type tag) to a variable, function or constant.
variant | variables of undeclared type; may hold any type | |
---|---|---|
string | $ | "How now brown cow!!!!" mystring$ |
boolean | true false | |
byte | 0 to 255 only | |
date | #1/1/1999# #26 Sep, 1944# | |
integer | % | 123 &O77 (=63) &H0F (=15) &HFF (=255) myint% |
long | & | 123& 487289365 &O77& &HFF& &HFF0000 mylong& |
single | ! | 4.8 3.14159! 1.e1 myreal! |
double | # | 4.8# .5d2# 1.d1 mydouble# |
currency | @ | 3.52@ 3.1235@ 45238924.12@mymoney@ |
type | a user defined type may be created by delarations bracketed by type and end type statements. |
string variables may hold up to 32767 characters unless declared as string*n where "n" sets the limit on the number of characters in the string.
integer variables are in the range -32768 through 32767
long variables are in the range -2,147,483,648 through 2,147,483,647
single variables are for non-integer numbers using seven or fewer
digits, while double variables are for non-integer numbers using 8
or more digits. On most systems single precision variable use the
4 byte IEEE single precision floating point format for numbers up to
approximately 3.e38, while
currency numbers use 8 bytes to represent numbers with up to 4 decimal digits, with more than 14 digits before the decimal point.
An array is a collection of objects which are accessed by one or more indices.
DIM variable( ilo TO ihi ) AS type DIM variable( ilo TO ihi, jlo TO jhi ) AS type DIM variable( ilo TO ihi, jlo TO jhi, klo TO khi ) AS type ...
If the lower index for any dimension is zero, it may be omitted.