Visual Basic s Compilation Options

[Previous] [Next]

Two Visual Basic settings greatly affect your ability to create consistently solid code: Compile On Demand and Background Compile. You set these on the General tab of the Options dialog box, shown in Figure 7-1.

When Compile On Demand is selected, Visual Basic doesn't fully compile your project when you click the Run button on the toolbar or press F5. Instead, procedures are compiled only as they're referenced. Compile On Demand often results in faster start times for larger projects or projects on slower computers, but it also causes some compile errors to go unnoticed.

NOTE
Pressing Ctrl+F5 or choosing Start With Full Compile from the Run menu causes the project to fully compile, regardless of the Compile On Demand setting.

click to view at full size.

Figure 7-1. The Compile On Demand and Background Compileoptions affect your ability to catch compile errors while developing.

You cannot compile a project into a distributable file such as an .exe file or a .dll file until all compile errors are found and corrected, so selecting Compile On Demand won't allow you to distribute code with compile errors. However, selecting Compile On Demand might allow compile errors to build up over time and force you to make many corrections to your code when you finally attempt a full compile. If you're debugging your project in the IDE, you might become frustrated because Visual Basic often has to completely stop (not just halt) execution to allow you to correct the problem. This makes correcting numerous compile errors while debugging a running project a tedious process. If your computer can fully compile the project in a reasonable amount of time, you might consider turning off Compile On Demand. Or you can leave Compile On Demand selected but periodically run your project by pressing Ctrl+F5. This allows you to regularly correct compile errors as you develop rather than having to correct numerous errors all at once.

When you select Compile On Demand, you can choose whether to select the Background Compile option as well. Selecting Background Compile causes procedures and modules to be compiled as they're referenced, but Visual Basic also uses idle time to compile modules that haven't yet been referenced. Over time, a project fully compiles. Using Background Compile allows you to enjoy the faster load times of running a project without full compilation while keeping compile errors to a minimum because you're alerted to errors in modules that are not being referenced. Once again, be aware that correcting compile errors often forces your project out of run mode, which can be a distraction during intense debugging sessions.



Practical Standards for Microsoft Visual Basic
Practical Standards for Microsoft Visual Basic .NET (Pro-Developer)
ISBN: 0735613567
EAN: 2147483647
Year: 2000
Pages: 57

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net