Databases Reference
In-Depth Information
TABLE 3.1
Variable Types in VBA and Their Storage Requirements
Data Type
Storage Size
Range
Byte
1 byte
0 to 255
Boolean
2 bytes
True
or
False
Integer
2 bytes
32,768 to 32,767
Long
4 bytes
2,147,483,648 to 2,147,483,647
(long integer)
Single
4 bytes
3.402823E38 to 1.401298E-45 for negative
values; 1.401298E-45 to 3.402823E38 for
positive values
(single-precision floating-point)
Double
8 bytes
1.79769313486231E308 to
4.94065645841247E-324 for negative values;
4.94065645841247E-324 to
1.79769313486232E308 for positive values
(double-precision floating-point)
Currency
8 bytes
922,337,203,685,477.5808 to
922,337,203,685,477.5807
(scaled integer)
Decimal
14 bytes
+
/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
Date
8 bytes
January 1, 100 to December 31, 9999
Object
4 bytes
Any
Object
reference
String
10 bytes
+
string length
0 to approximately 2 billion
(variable-length)
String
Length of string
1 to approximately 65,400
(fixed-length)
Variant
16 bytes
Any numeric value up to the range of a
Double
(with numbers)
Variant
22 bytes
+
string length
Same range as for variable-length
String
(with characters)
User-defined
(using
Number required by elements
The range of each element is the same as the
range of its data type
Type
)
Private Variables can only be utilized by procedures that reside in the same module as the Private Variable
was declared in. The
statement is used to declare private module-level variables.
Private
Examples:
Private CompoundNumber as String
Private AreaUnderCurve as Single
The
statement is also utilized to declare variables. When used at the module level, the
Dim
statement is equivalent to the
statement. It is best to utilize the
Statement
Dim
Private
Private
to make macro code more easy to read and interpret. When a variable is declared with the
Private
or
statement within a function or subroutine, it can only be utilized within the function or
subroutine in which it was declared.
Examples:
Dim
Dim LastName as String
Dim Age as Integer
 
Search WWH ::




Custom Search