Debugging

Using Step Into, Step Over and Step Out

Step Into

Stepping is the process of running one statement at a time. After stepping through a statement, you can see its effect in the other Debugging windows.

To step through code one statement at a time, choose Step Into from the Debug menu (F8), or press the button

When stepping intoa procedure, Visual Basic executes the current statement and then enters Break mode (see above). You can now edit any code and use the debugging tools. If the statement executed calls another procedure, Visual Basic will step into that procedure. Once you have stepped through all the statements in that procedure, Visual Basic will jump back to the next statement of the procedure it was called from. To go onto the the next statement, press the Step Into (F8) button again. If you press the play button (F5) code execution will continue as normal.

Step Over

Step Over is the same as Step Into, except that when it reaches a call for another procedure, it will not step into the procedure. The procedure will run, and you will be brought to the next statement in the current procedure.

To step through code one statement at a time, choose Step Into from the Debug menu (SHIFT+F8), or press the button.

For example, if you had the following code:

Sub GetData()
    Dim gName As String
    gName = InputBox("Enter your name")
    SetData(gName)
End Sub

Sub SetData(gName As String)
    Text1 = "Name: " & gName
End Sub

Both Step Into and Step Over would behave the same, until they reached SetData(gName) . Using Step Over, Visual Basic would run the SetData procedure, and the cursor would be moved to the next statement in that procedure (in this case, End Sub). Using Step Into, the cursor would be moved to the beginning of the SetData procedure

Step Out

If you are using Step Into and have been moved to a called procedure, you can automattically run the current procedure, and return to the procedure it was called from by pressing the Step Out (Ctrl+SHIFT+F8) on the Debug menu, or pressing the button.

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”