|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Adding Debug Watch WindowsYou 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 were watching the value in the variable intCounter.
Being able to continuously watch the values in your programs 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 DebuggingWhen 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.
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, heres how we check the value in a variable named intCounter: ?intCounter And heres how we check the value of the expression intCounter + 1: ?intCounter + 1 Visual Basic displays the values of the expressions youre 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 BreakpointsIf 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 DebuggingIt can be tedious to single-step through a great deal of code. There is another option, howeveryou 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 youve selected. Skipping Over Statements While DebuggingYou 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 dont want to execute) and select the Set Next Statement item in the Debug menu, or press Ctrl+F9.
|
|
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. |