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 first 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 fill 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 find 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.
Was this article helpful?