THE COMMAND AND IMMEDIATE WINDOWS

The Command and Immediate windows enable you to execute commands while the program is stopped in the debugger. One of the more useful commands in each of these windows is the Debug.Print statement. For example, in the Command window, the command Debug.Print x displays the value of the variable x. In the Immediate window, the statement must follow normal Visual Basic syntax so the command is Debug.Print(x).

You can use a question mark as an abbreviation for Debug.Print. The following text shows how the command might appear in the Command window. Here the > symbol is the command prompt provided by the window and 123 is the result: the value of variable x. In the Immediate window, the statement would not include the > character.

>? x
123

The command >immed tells the Command window to open the Immediate window. Conversely, the command >cmd (you need to type the > in the Immediate window) tells the Immediate window to open the Command window.

Although there is some overlap between these two windows, they serve two mostly different purposes. The Command window can issue commands to the Visual Studio IDE. Typically, these are commands that do or could appear in menus and toolbars. For example, the following command uses the Debug menu’s QuickWatch command to open a QuickWatch window for the variable first_name:

>Debug.QuickWatch first_name

One particularly useful command is Tools.Alias. This command lists command aliases defined by the IDE. For example, ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.