Sometimes you can find the cause of a problem by executing portions of code. More often, however, you'll also have to analyze what's happening to the data. You might isolate a problem in a variable or property with an incorrect value, and then have to determine how and why that variable or property was assigned an incorrect value.
With the debugging windows, you can monitor the values of expressions and variables while stepping through the statements in your application. There are three debugging windows: the Immediate window, the Watch window, and the Locals window
Figure 13.8 The Immediate window
For More Information To learn more about the Immediate window, see "Testing Data and Procedures with the Immediate Window" later in this chapter.
Figure 13.9 The Watch window
For More Information To learn more about the Watch window, see "Monitoring Data with Watch Expressions" later in this chapter.
Figure 13.10 The Locals window
The current procedure and form (or module) determine which variables can be displayed according to the scoping rules presented in "Understanding the Scope of Variables" in "Programming Fundamentals." For example, suppose the Immediate window indicates that Form1 is the current form. In this case, you can display any of the form-level variables in Form1. You can also use Debug.Print
to examine local variables of the procedure displayed in the Code window. (You can always examine the value of a public variable.) For more information about printing information in the Immediate window, see "Testing data and Procedures with the Immediate Window" later in this chapter.