4.2. Immediate Window

Quite often when you are writing code or debugging your application, you will want to evaluate a simple expression either to test a bit of functionality or to remind yourself of how something works. This is where the Immediate window comes in handy. This window enables you to run expressions as you type them. Figure 4-2 shows a number of statements — from basic assignment and print operations to more advanced object creation and manipulation.

Figure 4.2. Figure 4-2

Although you can't do explicit variable declaration (for example, Dim x as Integer), it is done implicitly via the assignment operator. The example shown in Figure 4-2 shows a new customer being created, assigned to a variable c, and then used in a series of operations.

The Immediate window supports a limited form of IntelliSense, and you can use the arrow keys to track back through the history of previous commands executed. Variable values can be displayed by means of the Debug.Print statement. Alternatively, you can use the ? alias.

In earlier versions of Visual Studio, your application had to be in Break mode (i.e., at a breakpoint or pausing execution) for the expressions to be evaluated. Although this is no longer a requirement, your solution cannot have any compile errors. When you execute a command in the Immediate window without being in Break mode, Visual Studio will build the solution ...

Get Professional Visual Studio® 2008 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.