Use the Debug window to debug your code. This window is automatically opened at run time . In break mode, you can use the Debug window to execute individual lines of code and to test your code. At run time, although you can't enter statements into the Debug window, you can use it to print internal values without printing them to the actual forms. You can also use the Debug window to monitor the value of expressions you have selected as watch expressions.
To open the Debug window, choose Debug from the Window menu.
To close the Debug window, double-click the window's Control menu .
The Debug window consists of:
The Watch pane. Located directly beneath the Debug window title bar, this pane is visible only if you have selected a watch expression to be monitored during code execution. The displayed information includes the context of the watch expression, the expression itself and its value at the time of the transition to break mode. If the context of the expression is not in scope when going to break mode, the current value is not displayed.
The Immediate pane. Located below the title bar or below the Watch pane if it is displayed, the Immediate pane is where you enter code to execute it immediately. While working in the Immediate pane:
You can execute only one line of code at a time.
You can type or paste a line of code and press Enter to run it.
You cannot save code, but you can copy and paste it into the Code window .
In break mode, a statement in the Debug window is executed in the context displayed in the Debug window title bar. For example, if you type Print variablename your output is the value of a local variable. This is the same as if the Print method had actually occurred in the procedure you were executing when the program halted.
Using the Debug Window
Learning Visual Basic:
Debugging Your Application
Chapter 9, "Debugging"