Single-Stepping Through Code


At any breakpoint, you can click the Debug toolbar's Step Into button to execute the next statement in the program. Whatever statement normally executes next (even if that statement is a call to another procedure) executes when you click Step Into.

The Debug toolbar contains three Step-related buttons; Table 36.1 describes how to use them. You might not want to single-step through every statement in an application; the Step buttons give you some options on how you want the program to continue.

Table 36.1 The Possible Step Modes

Step Mode

Description

Step Into

Executes only the next statement. Even if the statement is in another procedure or a return to a previous procedure, the next statement executes and you're placed at that next statement. Therefore, you can single-step through an entire application by pressing F8 continually.

Step Over

Executes the next statement unless the next statement is the call to a different procedure. The new procedure executes in its entirety and execution halts at the statement following the procedure call.

Step Out

Finishes executing the current procedure and then, at the next statement outside the procedure, execution halts again.

Of course, at any breakpoint, you can click the Start button to continue the execution in its normal manner. If subsequent breakpoints are set, the execution halts at those breakpoints. Otherwise, the program behaves normally as if you'd never stopped it.

You can terminate debug mode at any time by clicking the Visual Basic Toolbar's End button or by choosing End from theRun menu.