Microsoft Office Tutorials and References
In Depth Information
Table 4-7. Numeric Data Types
Negative values:
Signed double-precision 8 bytes
-1.79769313486231E308 to
floating-point number
Positive values:
4.94065645841247E-324 to
-32,768 to 32,767
Signed integer number
2 bytes
-2,147,483,648 to 2,147,483,647
Signed integer number
4 bytes
Negative values:
Signed single-precision
4 bytes
-3.402823E38 to -1.401298E-45
floating-point number
Positive values:
1.401298E-45 to 3.402823E38
Defining Constants
Some procedures will require a reference to a particular value that rarely, if ever, changes.
Rather than repeatedly entering the same value, you can create a reference, called a constant ,
for it. Defining a constant lets you specify the actual value only once in your code and use the
reference whenever you need it.
VBA itself has many built-in constants, called intrinsic constants , designed to make it easier
for you to work with the many functions available. For example, if you had a procedure to
create a line chart, you could use the intrinsic constant xlDot to make the line dotted in
Note You can display a list of the available intrinsic constants by typing intrinsic
constants in the Help box in the Visual Basic Editor.
You specify your own constants by using the Const statement, which works the same as the
Dim statement with the exceptions that you must supply the value of the constant and only
one constant can be declared on a line. The following lines declare two constants, the first a
byte value with the number of days in December and the second a Single variable with an
accepted value for pi.
Const conDaysDec as Byte = 31
Const conPi as Single = 3.1415929
Handling Strings
As mentioned earlier, there are other data types besides numeric ones. Variables can also hold
text values using the String data type. Strings can be either variable-length or fixed-length.
Search JabSto ::

Custom Search