Step Through Code

You can step through code when you are in Break mode.
There are several commands on the Debug menu that appear automatically when you are in Debug mode.
When you are testing code it is very useful to be able to step through the code one line at a time.
This can help you see what each line of code is doing and can be very helpful when trying to understand a complicated bit of code.
As each line of code is executed the appropriate action is taken and the corresponding line is highlighted in yellow.
Pressing F8 will execute the code one line at a time.
Immediately before a line of code is executed the line will appear with a yellow background.


Stepping Into

This is the term used that refers to moving to the first line of code inside another subroutine or function
This should be used when you want to step through all the lines of code including nested subroutines and functions.
If a subroutine or function only contains code that is commented out then it will be stepped over.


Sub One 
   Call Two()
   sValue:="text"
End Sub
Sub Two
Dim svalue As string
   sValue:="hello"
End Sub

Stepping Over

This is the term that refers to moving to the first line after a subroutine or function.
This should be used when you just want to execute a nested subroutine or function without stepping through it.
This is used when you are confident the code will execute successfully.


Sub One 
   Call Two()
   sValue="text"
End Sub
Sub One
   Call Two()
   sValue="text"
End Sub

Stepping Out

This is the term that refers to jumping to the first line of code that will execute after this subroutine or function.
This should be used when you have stepped into a subroutine or function and want to return to the subroutine or function that called it without stepping through the remaining lines of code.


Sub Two 
   sValue1 = "text"
  sValue2 = "more"
   Call Three
End Sub
Sub Three
   Call Two
   sValue = "hello"
End Sub

Run To Cursor

Right click a line of code that occurs after the line that is currently being executed and select "Run to cursor"
SS
This will execute all the code between the line that is currently being executed and the new cursor location


Set Next Statement

Right click a line of code that occurs after the line that is currently being executed and select "Set next statement"
SS
This will ignore all the code between the line that is currently being executed and the new cursor location.


Just My Code

Introduced in Visual Studio 2005
This allows you to only step through code that you have written.
Any automatically generated code or code from any referenced assemblies is executed without stepping through it.



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext