Microsoft 9GD00001 Computer Accessories User Manual


 
162 Microsoft Visual Studio 2010: A Beginner’s Guide
The Locals and Autos windows can sometimes become crowded with too many
variables and slow you down as your code gets more complex, especially when the
variables you’re interested in are at the bottom of the list or so far apart that you must
scroll between them. Another benefit of the Watch window is that you can drill down
into an object to show a value without continuously expanding the tree view. An
example of this is to type cust.Order.Total as shown in Figure 6-10, to see the results
of the Totals property of the Order property of the cust instance. In addition, you
can edit the values of your variables and properties in this window by either double-
clicking the current value shown in the Value column or right-clicking the variable
name and choosing Edit. When the value changes, it changes color from black to red to
let you know it has changed. This technique of editing your values on the fly comes in
quite handy, especially when you find yourself sliding the yellow arrow up to previous
lines of code in order to re-run them without restarting your program. These techniques
should prove to be a huge time saver.
The Immediate Window
While debugging, it’s often useful to type an expression to see the results at the current
time. The Immediate window allows you to type in variable names and many other types
of statements. You can access the Immediate window by selecting Debug | Windows, or it
may open for you automatically during debugging at the bottom-right side of VS.
You can
see the Immediate window being used in Figure 6-11.
The Immediate window in Figure 6-11 has three statements, showing that you can
read a property, execute a method, or evaluate an expression. I typed these statements in
myself, and you can do the same, writing nearly any code you want.
When evaluating an expression in VB, prefix the statement with a question mark, ?.
Figure 6-11 The Immediate window