Tracing Execution

See AlsoDF5LRH

Tracing execution is useful in Visual Basic because in event-driven programming, it may not be obvious which statement is executed first.  Use these techniques to trace the execution of code:

         Single steppingtracing through each line of the procedure.  This shows you the effect of each statement on variables.

         Procedure steppingexecuting each procedure as if it were a single statement.  Use this instead of single stepping to step across procedure calls rather than into the called procedure.

 

To trace execution from the current statement

        From the Debug menu, choose Single Step (F8), or use the toolbar shortcut to execute code one line at a time.

        From the Debug menu, choose Procedure Step (Shift+F8), or use the toolbar shortcut to step across procedure calls.

 

To trace execution from the beginning of the program in break mode9NQX0JY or run timeCYRM35

   1. From the Run menu, choose End, or use the toolbar shortcut:

     Visual Basic resets all variables, removes any suspended procedures from memory, and returns to design timeCFSL0V.

   2. From the Debug menu, choose Single Step (F8); or choose Procedure Step (Shift+F8).

     The program runs until the first event procedure or Sub Main begins executing.

 

Note   You can also set a breakpointBMA26TM or watch expression12QVKFC within a procedure before you start running the application.  When the application halts at the breakpoint, trace from that point.

 


See Also

Help:

Debugging Checklist4RVH0A6

Finding a Procedure1CNGZXN

 

Programmer's Guide:

Chapter 9, "Debugging"