QBasic Information Center Tutorials - Data Types
These tutorials were written to help you get a quick, but thorough, understanding of QBasic -
the scope of the language as well as it's specific capabilities.
There are several types of data in QBasic
strings "dog" "cat" "the_boy"
integers 1 7 -39 37 43 0
single 1.2 -17.4 83.2 171.006
user-defined (combination of above types, see explanation below)
All QBasic variables are one of these basic data types. In performing functions
which expect a particular type of data, QBasic will try, but may not succeed, to
adjust the type of data found in a variable to the type needed by the function.
Data Type Value Ranges
The minimum/maximum values of each data type is given in the next table.
In many programs a value of a specific data type is required. QBasic provides several
ways to convert variables to specific data types.
To convert any number to a specific data type, use one of the following functions.
To convert a string to a specific data type, use one of the following functions.
User-Defined Data Type (UDT)
QBasic also supports a very useful data type which consists of more than
one of the standard data types. In this example, a "Custom" data type is
defined and the variable X is defined as that data type. The example shows
how to assign and access the elements which make up a user-defined data type.
a as string
b as number
c as double
Dim X as Custom
X.a = "hello"
X.b = 5
X.c = 53.2429965
This technique allows you to carry multiple values around in a single
variable. You can write X to a file and save all three values in a single
If you have any suggestions for additions to these tutorials, please let me know.