Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Adding Debug Watch Windows

You can add a watch window to your debugging session and display the values of selected variables or expressions in that window continuously as you execute your program line by line.

To add a watch window, select the variable or expression you want to watch with the mouse and click the Add Watch item in the Debug menu. This opens the Add Watch dialog box; make sure the variable or expression you want to watch is entered in the Expression box and click on OK. When you do, Visual Basic adds a watch window to the debug session, as you can see at bottom in Figure 29.7, where we’re watching the value in the variable intCounter.


Figure 29.7  A debug watch window.

Being able to continuously watch the values in your program’s variables as the program executes can be a great asset in debugging, because you can see unexpected values as they appear.

Using The Immediate Window While Debugging

When debugging, you can use the Immediate window to examine expressions or variables immediately, just by typing them in. The Immediate window appears at lower left when Visual Basic is in its Debug state, as shown in Figure 29.8.


Figure 29.8  The Immediate debugging window.

You can enter an expression to evaluate in the Immediate window if you precede it with a question mark and then press the Enter key. For example, here’s how we check the value in a variable named intCounter:

?intCounter

And here’s how we check the value of the expression intCounter + 1:

?intCounter + 1

Visual Basic displays the values of the expressions you’re examining in the Immediate window (on the line after your query), as shown in Figure 29.8, where we see that intCounter holds a value of 1.

Clearing All Debugging Breakpoints

If you have a large number of breakpoints in a program, you might be relieved to learn that you can clear them all at once with the Clear All Breakpoints menu item in the Debug menu. The shortcut for this menu item is Ctrl+Shift+F9.

Executing Code Up To The Cursor While Debugging

It can be tedious to single-step through a great deal of code. There is another option, however—you can click a line of code to place the blinking text insertion caret at that line and select the Run To Cursor item in the Debug menu, or press Ctrl+F8. When you do, execution continues to the line you’ve selected.

Skipping Over Statements While Debugging

You can skip over lines of code when debugging a program. To do that, just click the line of code you want execution to start with (after having skipped the lines you don’t want to execute) and select the Set Next Statement item in the Debug menu, or press Ctrl+F9.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.