Section 3.2
Programming In QuickBASIC
3.2 Variables, Input And Output
3.2.1 Variable Names
Input and output data needs to be stored within the computer's memory.
Data is stored at a certain memory address. This box diagram represents an area of
memory.
Variable names mean that the programmer does not have to remember what data is stored
in which memory address.
In QuickBASIC names must not:
- exceed 40 characters in length.
- start with a digit.
- contain some certain non-alphanumeric characters.
- be distinguised from each other by variations in case.
- be a keyword.
3.2.2 Variable Types
Variables don't just come in one form.
There are:
Integers (2 bytes)
Any whole number from -32,768 to 32,767.
This is expressed as: variable_name%
or defined using the statement: DIM variable_name AS INTEGER
Long Integers (4 bytes)
Any whole number from -2,147,483,648 to 2,147,483,647.
This is expressed as: variable_name&
or defined using the statement: DIM variable_name AS LONG
Single Precision Floating Point Number (4 bytes)
Any real number with seven significant figures from -3.4×1038 to
3.4×1038.
This is expressed as: variable_name!
or defined using the statement: DIM variable_name AS SINGLE
Double Precision Floating Point Number (8 bytes)
Any real number with 15 significant figuresfrom -1.7×10308 to
1.7×10308.
This is expressed as: variable_name#
or defined using the statement: DIM variable_name AS DOUBLE
String
Any sequence of letters, symbols and numbers up to 32,767 characters in length.
This is expressed as: variable_name$
or defined using the statement: DIM variable_name AS STRING (length)