The Debug window allows you to set a watch on specific variables or properties to see what values they hold as your program executes. This will aid you in debugging by allowing you to analyze a variable or property that has an incorrect value and determine where the problem is coming from.
You can set the Debug window, as shown in Figure 7-3, by using Debug Add Watch from the menu.
You enter the variable or expression that you wish to monitor in the Expression box. For example, if you have a variable x and you wish to keep track of the value of it, you enter x into the box. The context details are entered automatically, although they can be amended. You can also specify whether you want the code to break when the value of the variable is True (nonzero) or when the value changes.
Click OK, and the Debug window will appear with details of your variable in it, as shown in Figure 7-4.
When the program reaches a breakpoint, the value in the Debug window is updated. As you step through, it will also be updated. You can delete a watch expression by highlighting the expression, clicking it, and then pressing the Delete key.
You can also edit the watch expression by right-clicking the selected expression and selecting Edit.