19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

can then alter the expression in the Expression text box <strong>and</strong> select one of the three Watch<br />

types. To delete an expression from the Watch window, right-click on the expression <strong>and</strong> then<br />

click on “Delete Watch.” To alter an expression in the Watch window, right-click on the<br />

expression <strong>and</strong> click on “Edit Watch.”<br />

THE LOCALS WINDOW<br />

The Locals window, invoked by clicking on “Locals Window” in the View menu, is a<br />

feature that was new to <strong>Visual</strong> <strong>Basic</strong> in version 5.0. This window automatically displays the<br />

names, values, <strong>and</strong> types of all variables in the current procedure. See Figure D.3. You can<br />

alter the values of variables at any time. In addition, you can examine <strong>and</strong> change properties<br />

of controls through the Locals window.<br />

FIGURE D.3 The Locals Window<br />

STEPPING THROUGH A PROGRAM<br />

The program can be executed one statement at a time, with each press of an appropriate function<br />

key executing a statement. This process is called stepping (or stepping into). After each<br />

step, values of variables, expressions, <strong>and</strong> conditions can be displayed from the debugging<br />

windows, <strong>and</strong> the values of variables can be changed.<br />

When a procedure is called, the lines of the procedure can be executed one at a time,<br />

referred to as “stepping through the procedure,” or the entire procedure can be executed at<br />

once, referred to as “stepping over a procedure.” A step over a procedure is called a procedure<br />

step. In addition, you can execute the remainder of the current procedure at once,<br />

referred to as “stepping out of the procedure.”<br />

Stepping begins with the first line of the first event procedure invoked by the user. Program<br />

execution normally proceeds in order through the statements in the event procedure.<br />

However, at any time the programmer can specify the next statement to be executed.<br />

As another debugging tool, <strong>Visual</strong> <strong>Basic</strong> allows the programmer to specify certain lines<br />

as breakpoints. Then, when the program is run, execution will stop at the first breakpoint<br />

reached. The programmer can then either step through the program or continue execution to<br />

the next breakpoint.<br />

The tasks discussed previously are summarized below, along with a means to carry out<br />

each task. The tasks invoked with function keys can also be produced from the menu bar.<br />

Step Into: Press F8<br />

Step Over: Press Shift+F8<br />

Step Out: Press Ctrl+Shift+F8<br />

Set a breakpoint: Move cursor to line, press F9<br />

Remove a breakpoint: Move cursor to line containing<br />

breakpoint, press F9<br />

Clear all breakpoints: Press Ctrl+Shift+F9<br />

Set next statement: Press Ctrl+F9<br />

Continue execution to next breakpoint<br />

or the end of the program: Press F5<br />

Run to cursor: Press Ctrl+F8<br />

Appendix D 459

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!