I am a supporter of St. Joseph's hospice. If you find this site useful or if it helped you, consider a small donation to St. Joseph's, please.
Variables are very useful to store temporary data during execution of your code. You can store different types of data:
|
Type |
Variable Examples |
Value Examples |
Comment |
|
Boolean |
bProcessed |
True, False |
Values 0 (False) or 1 (True) |
|
Byte |
btChar |
&H0F, 253 |
Value range 0 - 255 |
|
Currency |
ccyEUR |
123.01 |
Value range -922,337,203,685,477.5808 to |
|
Date |
dtBirthday |
#12/31/1980# |
Value range 1 January 100 to 31 December 9999 and times from 0:00:00 to 23:59:59. |
|
Decimal |
decDist |
123789.12 |
With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With a 28 decimal places, the largest value is +/-7.9228162514264337593543950335 and the smallest, non-zero value is +/-0.0000000000000000000000000001 |
|
Double |
dPi |
3.14159265 |
-1.79769313486231E308 to -4.94065645841247E-324 for negative values and from 4.94065645841247E-324 to 1.79769313486232E308 for positive values |
|
Integer |
intAge |
123 |
Value range -32,768 to 32,767 |
|
Long |
lIndex |
17167 |
Value range -2,147,483,648 to 2,147,483,647 |
|
LongLong |
llBigNum |
123152367765 |
Only available for 64 bit systems: value range |
|
LongPtr |
lptr |
131313123 |
signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647 on 32-bit systems; and signed 64-bit (8-byte) numbers ranging in value from -9,223,372,036,854,775,808 to |
|
Object |
|
|
|
|
Single |
sngNum |
1.2345 |
Value range -3.402823E38 to -1.401298E-45 for negative values and from 1.401298E-45 to 3.402823E38 for positive values |
|
String |
sName |
"Bernd" |
Codes for String characters range from 0–255 |
|
User defined |
|
|
|
|
Variant |
vA |
|
Value range -1.797693134862315E308 to -4.94066E-324 for negative values and from 4.94066E-324 to 1.797693134862315E308 for positive values. Generally, numeric Variant data is maintained in its original data type within the Variant. For example, if you assign an Integer to a Variant, subsequent operations treat the Variant as an Integer. However, if an arithmetic operation is performed on a Variant containing a Byte, an Integer, a Long, or a Single, and the result exceeds the normal range for the original data type, the result is promoted within the Variant to the next larger data type. A Byte is promoted to an Integer, an Integer is promoted to a Long, and a Long and a Single are promoted to a Double. An error occurs when Variant variables containing Currency, Decimal, and Double values exceed their respective ranges |
More complex types of variables are arrays.
- Ozgrid on variables (explains scope and lifetime, too)
- Leszynski naming convention
Exceptions: (no variables but also useful constructs) constants, enumerations.
An example:


Constants you can set to fix values at the beginning of your code. You refer to them from anywhere in your code. If you need to change them, you only need to do so in one location.
Enumerations are good for lists or to give columns subsequent numbers. If you need to alter or to enhance your list or if you need to insert or to move a column, you only need to do so in your enumeration.
[Sulprobil] [Get it done] [Organisation] [IT] [Controlling] [Human Resources] [Family] [Contact] [Download] [Disclaimer]