Datasheet
52
❘
CHAPTER 1 VISUAL STUDIO 2010
tree - control interface. It also supports the editing of those values, so if you want to change a string from empty
to what you thought it would be, just to see what else might be broken, then feel free to do so from here.
Watch Windows
There are four Watch windows, numbered Watch 1 to Watch 4. Each window can hold a set of variables or
expressions for which you want to monitor the values. It is also possible to modify the value of a variable
from within a Watch window. The display can be set to show variable values in decimal or hexadecimal
format. To add a variable to a Watch window, you can either right - click the variable in the Code Editor and
then select Add Watch from the pop - up menu, or drag and drop the variable into the watch window.
Immediate Window
The Immediate window, as its name implies, enables you to evaluate expressions. It becomes available while
you are in Debug mode. This is a powerful window, one that can save or ruin a debug session. For example,
using the sample from earlier in this chapter, you can start the application and press the button to stop on
the breakpoint. Go to the Immediate window and enter ?Button1.Text = “ Click Me ” and press Enter. You
should get a response of false as the Immediate window evaluates this statement.
Notice the preceding ? , which tells the debugger to evaluate your statement, rather than execute it. Repeat
the preceding text but omit the question mark: Button1.Text = “ Click Me ” . Press F5 or click the Run button
to return control to your application, and notice the caption on your button. From the Immediate window
you have updated this value. This window can be very useful if you are working in Debug mode and need to
modify a value that is part of a running application.
Autos
Finally, as the chapter prepares to transition to features that are only available in Visual Studio and not
Visual Basic 2010 Express, there is the Autos window. The Autos window displays variables used in the
statement currently being executed and the statement just before it. These variables are identifi ed and listed
for you automatically, hence the window ’ s name. This window shows more than just your local variables. For
example, if you are in Debug mode on the line to open the MessageBox in the ProVB_VS2010 sample, then
the MessageBox constants referenced on this line are shown in this window. This window enables you to
see the content of every variable involved in the currently executing command. As with the Locals window,
you can edit the value of a variable during a debug session. However, this window is in fact specifi c to
Visual Studio and not available to users of Visual Basic 2010 Express.
Reusing Your First Windows Form
As you proceed through the book and delve further into the features of Visual Basic you ’ ll want a way to
test sample code. Chapter 2 in particular has snippets of code which you ’ ll want to test. One way to do this
is to enhance the ProVB_VS2010 application. Its current use of a MessageBox isn ’ t exactly the most useful
method of testing code snippets. So let ’ s update this application so it can be reused in other chapters and at
random by you when you are interested in testing a snippet.
At the core you ’ ll continue to access code to test where it can be executed from the ButtonTest Click event.
However, instead of using a message box, you can use a text box to hold the output from the code being tested.
The fi rst step in this process as shown in Figure 1 - 33 is to drag a
TextBox control onto the display and then
click on the small arrow in the upper - right corner of the control ’ s display. This will open the TextBox tasks
menu, which contains some of the most common customizations for this control. This small arrow appears
on all Windows Forms controls, although what is listed will vary between controls. In this case you should
select the MultiLine property.
Once you have selected that property it is possible to expand the
TextBox to allow you to fi ll the entire bottom
portion of the window. As shown in Figure 1 - 34, you can then move to the properties for the TextBox control
and update the Anchor property to anchor the current control ’ s size based on the window containing it. Having
tied this control to all four sides of the window, when the window is resized, this control will automatically
resize with the window. You ’ ll fi nd if you review the properties of ButtonTest that it is anchored only to the
top and left sides of the window, so it remains unchanged while the window changes size.
CH001.indd 52CH001.indd 52 4/5/10 11:57:01 AM4/5/10 11:57:01 AM