New Tools to Make Debugging Easy
There are numerous tools in Visual Basic to help you debug your code.
- Breakpoints. A breakpoint defines a statement or set of conditions at which Visual Basic automatically stops your program and puts the code in break mode without running the statement containing the breakpoint. You can use breakpoints to examine your code and variables at places in your procedures where you think errors are occurring.
- Debugging buttons. The debugging buttons are included on the Visual Basic toolbar, which is displayed whenever a Visual Basic module is active. You can use these buttons to run your code one statement or procedure at a time, to control breakpoints, and to examine values of variables and expressions.
- The Debug window. You can use the Step Into command on the Run menu to display the Debug window. Using the Debug window, you can monitor the values of expressions and variables while running your code one statement at a time. You can also use this window while running your code to change the value of variables and properties to see how different values affect your code.
The Debug window contains three areas:
- The Immediate pane, which displays results from debugging statements in your code. You can also request debugging information by typing commands directly in the Immediate pane.
- The Watch pane, which displays expressions whose values you've decided to monitor as your code runs.
- The Code pane, which displays the most recently executed statement and allows you to browse surrounding pieces of code.
For more information about these tools and other aspects of debugging in Microsoft Excel, see Chapter 6, "Debugging."