Stepping means executing code one line at a time. The Debug menu provides three commands for stepping through code:
Step Into and Step Over both instruct the debugger to execute the next line of code. They differ only when that next line of code is the call of a procedure. Step Into steps into the called procedure; execution next halts at the first line of the called procedure. By contrast, Step Over steps over the entire called procedure, executing the called procedure but not stopping within it, and then halts at the next line of the calling procedure.
For example, assume that in the Division project execution had halted in the Click event procedure of lblDiv at the call of the subroutine performDivision:
With Step Into, execution next would halt at the first line of code within performDivision. By contrast, with Step Over, performDivision would be executed, and execution next would halt at the next line of code in the Click event procedure of lblDiv. Notwithstanding the term step over, Step Over does not skip execution of the called procedure, it just does not break your application within the called procedure.
Whether you use Step Into or Step Over usually depends on how far along you are in debugging your project. If you have just started, you probably will use Step Into, as you may not know at that early point whether the problem is in the calling procedure or the called procedure. Additionally, Step Into gives you an excellent view of the actual flow of your code. However, if you have determined that the problem is not in the called procedure, then executing its code one line at a time would be a waste of time, and you would use Step Over instead.
You use Step Out when you are inside the called procedure and want to return to the calling procedure. Step Out resumes execution of your code until the called procedure ends, and then halts execution in the calling procedure.
Was this article helpful?