Databases Reference
In-Depth Information
10.4.2.1 Option Explicit
To avoid this problem, we need a way to make Access refuse to run a program if it
contains any variables that we have not explicitly declared. This is done simply by
placing the line:
Option Explicit
in the Declarations section of each code module. Since it is easy to forget to do this, VBA
provides an option called Require Variable Declaration in its Options dialog box. When
this option is selected, VBA automatically inserts the Option Explicit line for us.
Therefore, I strongly recommend that you enable this option.
Now let us briefly discuss some of the data types in Table 10-1.
10.4.3 Numeric Data Types
The numeric data types include Integer, Long, Single, Double, and Currency. A long is
also sometimes referred to as a long integer .
10.4.4 Boolean Data Type
A Boolean variable is a variable that takes on one of two values: True or False . This is a
very useful data type that was only recently introduced into VBA. Prior to its
introduction, VBA recognized 0 as False and any nonzero value as True , and you may
still see this usage in older code.
10.4.5 String Data Type
A string is a sequence of characters. (An empty string has no characters, however.) A
string may contain ordinary text characters (letters, digits, and punctuation), as well as
special control characters such as vbCrLf (carriage return/line feed characters) or vbTab
(tab character). As we have seen, a string constant is enclosed within quotation marks. An
empty string is denoted by a pair of adjacent quotation marks, as in:
EmptyString = ""
There are two types of string variables in VBA: fixed-length and variable-length. A
fixed-length string variable is declared as follows:
Dim FixedStringVarName As String * StringLen
where StringLen specifies the number of characters reserved for the string. For instance,
the following statement declares a fixed-length string of length 10 characters:
Dim sName As String * 10
Search WWH ::




Custom Search