|
The non-string variables we've used in this tutorial are actually called single-precision variables. These types of variables (SINGLE's) are used to store numbers that can contain a decimal value (such as 1.89 or 3.141593). Since they have decimal values, they are also known as "floating-point" variables. This chapter describes other types of variables used in QBasic.
LONG - Same as INTEGER, but can contain numbers between DOUBLE - Same as SINGLE, but can have twice as many digits. To define a variable's type, use DIM with the AS attribute.
DIM var2 AS LONG DIM var3 AS DOUBLE var1 = 15.28 var2 = -2000000000 var3 = 12345678.12345678 PRINT var1 PRINT var2 PRINT var3
-2000000000 12345678.12345678 Using special characters You can use special characters to specify a variable's type. These characters can also be used to specify a number's type. To do so, place one of the following at the end of a variable (or number):
% (integer) & (long) # (double) $ (string--as we already know) Example (notice the number sign on 12345678.12345678):
var2& = -2000000000 var3# = 12345678.12345678# PRINT var1% PRINT var2& PRINT var3#
-2000000000 12345678.12345678 Feel free to distribute this tutorial, upload it to your website, link to it from your site, etc. http://www.geocities.com/progsharehouse/qbtutor Mirror: http://development.freeservers.com/qbtutor |