STEPPING THROUGH CODE


The VBE's step commands cause the compiler to execute either a single instruction or a limited set of instructions and then pause in break mode, highlighting the next instruction that will be executed. Execution is suspended until you take another action.such as issuing another step command, resuming normal execution, or terminating execution.

By issuing step commands repeatedly, you can follow the procedure's execution path. You can see, for example, which way the program branches when it comes to an If statement, or which of the alternative paths it takes when it encounters a Select Case structure. (A Select Case structure causes the program to execute one of a set of alternative statements, depending on the value of a particular variable. For details, type case in a module and press F1.)

You can also examine the values of variables at each step along the way.

You have four step commands at your disposal. You will find these commands and their keyboard shortcuts on the Debug menu:

  1. Step Into executes the next instruction only.
  2. Step Over works like Step Into unless the next instruction is a call to another procedure. In that case, Step Into executes the entire called procedure as a unit.
  3. Step Out executes the remaining steps of the current procedure.
  4. Run To Cursor executes everything up to the current cursor position
    You can run an entire procedure one step at a time by repeatedly pressing F8 (the keyboard shortcut for Debug, Step Into). To begin stepping through a procedure at a particular instruction, move your cursor to that instruction and press Ctrl+F8 (the shortcut for Debug, Run To Cursor). Alternatively, you can force the compiler to enter break mode when it reaches a particular instruction, and then use any of the step commands.