Microsoft Office Tutorials and References
In Depth Information
The Options dialog box within the Visual Basic Editor also has several options that affect the
Visual Basic Editor environment. The controls in the Options dialog box are organized on
four tabs: Editor, Editor Format, General, and Docking.
The Editor tab, shown in Figure 4-5, is further divided into two sets of options. The first set,
Code Settings, controls the display of IntelliSense tool tips, code formatting, variable decla
ration, and syntax errors. Auto Quick Info provides information on functions and their
parameters as you type them, as well as applicable intrinsic constants during design mode.
In run-time mode, Auto Data Tips provide the value of a variable when the mouse is hovered
over it. Code formatting options include Auto Indent, which indents new lines to the same
position as the line above it, and Tab Width, which sets the number of spaces one tab will
occupy. Turning on the Require Variable Declaration option will prevent you from attempt
ing to use a value in a variable you haven’t defined yet, and the Auto Syntax Check option will
check each line of code for syntax errors as it is entered. Finally, selecting the Auto List Mem
bers check box causes the Visual Basic Editor to display information that could be used to
complete a statement you’re typing.
Figure 4-5. The Editor tab of the Options dialog box gives you the tools to change how code,
errors, and tips are displayed in the Visual Basic Editor.
Avoiding Errors Through Declarations
Requiring yourself to define a variable before you use it might be annoying, but it can
prevent one of the most mysterious errors in programming: the divide by zero error. A simple
case of attempting to divide by zero would be if you want to find the average temperature for
a week. If you try to divide the sum of the temperatures by a new variable named
intNumDays , to which you have not assigned a value, the program will assume the value is
zero and generate the error.