Stepping through a Program


[Page 628 (continued)]

The program can be executed one statement at a time, with each press of an appropriate function key executing a statement. This process is called stepping. After each step, values of variables, expressions, and conditions can be displayed in the debugging windows, and the values of variables can be changed.

When a procedure is called, the lines of the procedure can be executed one at a time, referred to as stepping into the procedure, or the entire procedure can be executed at once, referred to as stepping over a procedure. A step over a procedure is called a procedure step. In addition, you can execute the remainder of the current procedure at once, referred to as stepping out of the procedure. The three toolbar buttons shown in Figure D.1 can be used for stepping.

Figure D.1. The toolbar buttons used to Step Into, Step Over, and Step Out.


As another debugging tool, Visual Basic allows the programmer to specify certain lines as breakpoints. Then, when the program is run, execution will stop at the first breakpoint reached. The programmer can then either step through the program or continue execution to the next breakpoint. Also, the programmer can place the cursor on any line in the program and have execution stop at that line with a "Run to Cursor" command. Program execution normally proceeds in order through the statements in the procedure. However, at any time the programmer can specify the next statement to be executed.

The tasks discussed previously are summarized next, along with a means to carry out each task. The tasks invoked with function keys also can be produced from the menu bar, the context menu (produced by clicking the right mouse button), or the toolbar.


[Page 629]

Run to cursor

Press Ctrl + F8

Step Into

Press F8

Step Over

Press Shift + F8

Step Out

Press Ctrl + Shift + F8

Set a breakpoint

Move cursor to line, press F9

Remove a breakpoint

Move cursor to line containing breakpoint, press F9

Clear all breakpoints

Press Ctrl + Shift + F9

Continue execution to next

 

breakpoint or the end of the program

Press F5

Stop debugging

Ctrl + Alt + Break





An Introduction to Programming Using Visual Basic 2005
Introduction to Programming Using Visual Basic 2005, An (6th Edition)
ISBN: 0130306541
EAN: 2147483647
Year: 2006
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net