This section describes two specific items or settings that we recommend you take advantage of when configuring your VBA options.
Require Variable Declaration
Although it is not required, you should use the Option Explicit statement in the Declarations section of a module to require variable declaration. The Option Explicit statement forces you to use variables that have already been declared as a certain type. Using the Option Explicit statement will help you avoid a common programming error and will shorten your debugging time.
To configure VBA to automatically add the Option Explicit statement to a new project:
- On the Tools menu, click Options.
- Select the Editor tab.
- Select the Require Variable Declaration check box.
- Click OK to activate this new option for all modules.
From this point on, when you create a new module, the Option Explicit statement will be added automatically. To learn more about setting VBA Editor options, click the Help button in the Options dialog box.
Clear the Compile On Demand Check Box
The Compile On Demand option, located on the General tab of the Options dialog box, determines whether a project is fully compiled before it starts, or whether code is compiled as needed, allowing the application to start sooner. We recommend that you clear this check box so you can more easily debug errors in your code.
WARNING: Do not enable the Notify Before State Loss option, located on the General tab of the Options dialog box. Doing so may cause an error or interruption in the iFIX WorkSpace.