The Options Dialog

The Options dialog box, shown in Figure 1-11, lets you customize the IDE's look and feel, including syntax color scheme, source code font, and tab spacing. To open the Options dialog box, choose Tools > Options. This section covers the most commonly used options.

Figure 1-11. The Options dialog box

For most developers, the default settings are fine. However, you should consider changing two settings on the Editor tab: Auto Syntax Check and Require Variable Declaration.

When the Auto Syntax Check option is checked, syntax errors in your code generate an error message similar to Figure 1-12.

As you begin to develop more complex applications and reuse lines of code from other places in your application, these error messages will become a nuisance. Any time you move the cursor off the offending line of code, you get one of these error messages. But if you uncheck Auto Syntax Check, the VBAIDE notifies you of errors by changing the color of the offending line of code to red.

The Require Variable Declaration option is unchecked by default, meaning that the VBAIDE does not require that you properly declare your variables before you use them. This isn't much of a concern when you write a simple macro, but when you start developing larger and more complex applications, you'll find this option indispensable. Checking this option forces you to think about each variable and its data type. When you check this option, the VBAIDE adds a line of code to the start of each module, as shown in Figure 1-13.

Figure 1-12. The error-message dialog box

Figure 1-13. An example of the checked Require Variable Declaration

Figure 1-13. An example of the checked Require Variable Declaration

After you check this option, exit and restart AutoCAD to make it take effect. By declaring variables to be a specific data type, you save memory resources. Undeclared variables are, by default, assigned the variant data type. This data type uses the most memory and could lead to memory resource problems when users run your application. As a rule of thumb, always declare each variable you use in your application, and choose the data type that uses the least possible memory. Chapter 2 discusses data types and memory in more detail.

0 0

Post a comment