1.8. Test-Driving a Visual Basic Application In this section, you will "test-drive" a Visual Basic application that enables you to draw on the screen using the mouse. You will run and interact with the working application. You'll build a similar application in. Chapter 13, Graphical User Interface Concepts: part 1. The Drawing application allows you to draw with different brush sizes and colors. We use fonts to distinguish between IDE features (such as menu names and menu items) and other elements that appear in the IDE. Our convention is to emphasize IDE features (such as the File menu) in a bold sans-serif Helvetica font and to emphasize other elements, such as file names (e.g., Form1.vb), in a sans-serif Lucida font. The following steps show you how to test-drive the application. 1. | Checking your setup. Confirm that you have installed Visual Basic 2005 Express or Visual Studio 2005 as discussed in the Preface. | 2. | Locating the application directory. Open Windows Explorer and navigate to the C:\examples\Ch01\Drawing directory. | 3. | Running the Drawing application. Now that you are in the correct directory, double click the file name Drawing.exe to run the application (Fig. 1.2). Figure 1.2. Visual Basic Drawing application. In Fig. 1.2, several graphical elementscalled controlsare labeled. The controls include two GroupBoxes (in this case, Color and Size), seven RadioButtons and a Panel (these controls will be discussed in depth later in the text). The Drawing application allows you to draw with a red, blue, green or black brush of small, medium or large size. You will explore these options in this test-drive. You can use existing controlswhich are objectsto get powerful applications running in Visual Basic much faster than if you had to write all of the code yourself. In this text, you will learn how to use many preexisting controls, and how to write your own program code to customize your applications. The brush's properties, selected in the RadioButtons (the small circles where you select an option by clicking the mouse) labeled Black and Small, are default settings, which are the initial settings you see when you first run the application. Programmers include default settings to provide reasonable choices which the application will use if the user chooses not to change the settings. You will now choose your own settings. | | | 4. | Changing the brush color. Click the RadioButton labelled Red to change the color of the brush. Hold the mouse button down with the mouse pointer positioned anywhere on the white Panel, then drag the mouse to draw with the brush. Draw flower petals as shown in Fig. 1.3. Then click the RadioButton labeled Green to change the color of the brush again. Figure 1.3. Drawing with a new brush color. | 5. | Changing the brush size. Click the RadioButton labeled Large to change the size of the brush. Draw grass and a flower stem as shown in Fig. 1.4. Figure 1.4. Drawing with a new brush size. | | | 6. | Finishing the drawing. Click the RadioButton labeled Blue. Then click the RadioButton labeled Medium. Draw raindrops as shown in Fig. 1.5 to complete the drawing. Figure 1.5. Finishing the drawing. | 7. | Closing the application. Click the close box, to close your running application. | Additional Applications in Visual Basic 2005 for Programmers, 2/e Figure 1.6 lists a few of the applications in the book's examples. We encourage you to run them. The examples folder for Chapter 1 contains all of the files required to run each application listed in Fig. 1.6. Simply double click the file names for any application you would like to run. [Note: The Garage.exe application assumes that the user inputs a value from 0 to 24.] Figure 1.6. Examples of Visual Basic applications found in this book.Application name | File to execute |
---|
Parking Fees | Garage.exe | Tic Tac Toe | TicTacToe.exe | Drawing Stars | DrawStars.exe | Drawing Shapes | DrawShapes.exe | Drawing Polygons | DrawPolygons.exe | |