Stepping through a Procedure

1. Place the insertion point anywhere inside the code of the procedure whose execution you wish to trace.

2. Press F8 or choose Debug | Step Into. Visual Basic executes the current statement and automatically advances to the next statement and suspends execution. While in break mode, you can activate the Immediate window, Watches window, or Locals window to see the effect of a particular statement on the values of variables and expressions. And, if the procedure you are stepping through calls other procedures, you can activate the Call Stack window to see which procedures are currently active.

3. Press F8 again to execute the selected statement. After executing this statement, Visual Basic will select the next statement, and the procedure execution will be halted again.

4. Continue stepping the procedure by pressing F8, or press F5 to continue the code execution without stopping. You can also choose Run | Reset to stop the procedure at the current statement without executing the remaining statements.

When you step over procedures (Shift+F8), Visual Basic executes each procedure as if it were a single statement. This option is particularly useful if a procedure contains calls to other procedures and you don't want to step into these procedures because they have already been tested and debugged or you want to concentrate only on the new code that has not yet been debugged.

0 0

Post a comment