Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


428


Table 11.1 describes the 12 fundamental data types supported by VBA.

TABLE 11.1

VBA Data Types


Data Type Range Description

Boolean True or false 2 bytes
Byte 0 to 255 1-byte binary data
Currency –922,337,203,685,477,5808 to
922,337,203,685,477,5807

8-byte number with fixed
decimal point
Decimal +/–79,228,162,514,264,337,593,543,950,335
with no decimal point
+/–7.9228162514264337593543950335
with 28 places to the right of the decimal;
smallest nonzero number is
+/–0.0000000000000000000000000001

14 bytes

Date 01 Jan 100 to 31 Dec 9999 8-byte date/time value
Double –1.79769313486231E308 to
–4.94065645841247E–324 for negative values
and 4.94065645841246544E-324 through
1.79769313486231570E+308 for positive
values

8-byte floating-point number

Integer –32,768 to 32,767 2-byte integer
Long –2,147,483,648 to 2,147,483,647 4-byte integer
Object Any object reference 4 bytes
Single –3.402823E38 to –1.401298E–45 for negative
values and 1.401298E–45 to 3.402823E38 for
positive values

4-byte floating-point number

String (variable length;
10 bytes plus length of
string)

0 to approximately 2,000,000,000 Varies by size of data

String (fixed length) 1 to approximately 65,400 Length of string
Variant (with numbers) Any numeric value up to the range of the
double data type (see earlier in this table)

16 bytes

Variant (with characters;
22 bytes plus length of
string)

0 to approximately 2,000,000,000 Varies by size of data

Most of the time, you use the string, date, integer, and currency or double data types. If
a variable always contains whole numbers between –32,768 and 32,767, you can save bytes of
memory and gain speed in arithmetic operations if you declare the variable an integer data type.
Free download pdf