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 mode or run time
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 time .
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 breakpoint or watch expression within a procedure before you start running the application. When the application halts at the breakpoint, trace from that point.
Finding a Procedure
Chapter 9, "Debugging"