Specifications

Chapter 13 229
Use of Macros
Making/Editing Macros
13. Use of Macro
Debugging macros
In order to eliminate disruptive errors (bugs) from macros, the operation of debugging is
necessary. E4991A VBA has a tool that can search for bugs and resolve such situations.
Types of bugs and debugging
The following types of bugs are the most common.
Syntax error (compile error)
A syntax error occurs by inputting a statement that violates the grammar rules of Visual
Basic. For example, an error in spelling is a syntax error. E4991A VBA shows error
messages in the error dialogue box and indicates the origin of an error in red. To better
understand the details of an error, click the
HELP button in the error dialogue box. A
macro cannot be executed until any syntax error is resolved.
In the initial settings, the function that automatically searches for syntax errors is
activated. However, you can freely turn on/off the automatic syntax error checking
function.
Step 1. In Visual Basic Editor, turn on/off the automatic syntax error checking function by the
following menu command.
Tools - Options... - Auto Syntax Check
Execution error
Such errors occur while executing a macro. This type of error normally interrupts the
program or ends it at unexpected places. If the program is interrupted, it can be stopped
by clicking the
END button in the error dialogue box. In addition, if the DEBUG button
is available in the error dialogue box, you can click it to specify the cause of the error.
After doing this, the error is highlighted in yellow.
Logic error
A logic error is a type of human error. For example, programming to control the
E4991A might stipulate that dc bias be applied and measured. However, if dc bias is
not applied, the expected measurement will not be complete, even though you can
execute the macro without any problem. Since E4991A VBA does not return an error
in this case, the programmer must specify the cause of the error himself. In order to find
the logic error, break points must be set up in suspected places, and the performance is
confirmed through stepwise execution of statement performance. E4991A VBA has a
debug tool for this purpose. For more on how to use the debug tool, please refer to
E4991A VBA help.
Step 1. In Visual Basic Editor, you can display the debug tool by the following menu command.
View - Tool bars - Debug