In this blog post we take a look at some of the options available in the Visual Basic Editor (press ALT + F11 to open).
VBA has a concise set of options and tools which you can set to change behaviour of the editor and debugger. All are useful tools to help make coding easier and quicker for developers.
To access the Editor Options, click on the Tools menu and select Options… |
- Auto Syntax check – check as you type syntax checker.
- Require Variable Declarations – this adds “Option Explicit” to the top of all modules and is good to always have ticked.
- Auto indent
Auto indent option forces the Editor to indent your code which makes ascertaining the beginning and end of nested methods easier.In the image to the right there is a For…Next loop and because the inner code block is indented it is easy to make out what is being executed and when.
|
Public Function debugTest() Dim a As Integer Dim b As Integer b = 10 a = 1 For a = 1 To b Debug.Print a a = a + 1 Next Debug.Print "The End" End Function |
- Break On All Errors (General Tab)
This option tells the debugger to break execution and let the programmer see the debugger and investigate what’s happening on ALL errors (handled or otherwise). If this option is not checked the debugger will not cut in and the program is left to perform default actions based on the nature of the error.
- Compile On Demand (General Tab)
Compilation is an operation that converts our VBA into executable code. Compile On Demand should generally always be on, and will be executed by the IDE or the module compiled when a function or procedure held within is required.
- Auto-Quick Info (Editor Tab)
Quick information enables the edit to provide you with the signature of a method displaying its accepted arguments and their data types – including enumeration types.
The hint below the Update tells you all the arguments this method requires. Both arguments in this method are optional as they have [] around them. UpdateType is of data type Long with a default value of 1, Force is of Boolean data type with a default value of False.
- Auto Data Tips (Editor Tab)
Earlier we saw that placing the curser over a variable in debug mode displays a hint. This option turns that feature on and off.
The Visual Basic Editor options above are worth learning as they can make writing and debugging code much simpler.
Related Posts
Basic Tools for Writing Code Visual Basic EditorCompilation Explained Visual Basic Editor
Debugging Visual Basic Editor
Immediate Window Visual Basic Editor
Opening The VBA Editor Visual Basic Editor
The VBA Editor Explained Visual Basic Editor