1. Click the New Project button on the toolbar.
2. In the the New Project dialog box, select Visual Basic in the Project Types tree-view box to the left and then select Windows beneath it. The Templates box on the right will display all of the available templates for the project type chosen. Select the Windows Forms Application template.
Finally, type Hello User in the Name text box and click OK. Your New Project dialog box should look like Figure 7.
Visual Studio 2008 allows you to target your application to a specific version of the Microsoft .NET Framework. The combo box in the upper right corner of the New Project dialog box has version 3.5 selected, but you can target your application to version 3.0 or even version 2.0 of the .NET Framework.
The IDE will then create an empty Windows application for you. So far, your Hello User
program consists of one blank window, called a Windows Form (or sometimes just a form),
with the default name of Form1.vb, as shown in Figure 8.
Whenever Visual Studio 2008 creates a new file, either as part of the project creation process or
when you create a new file, it will use a name that describes what it is (in this case, a form)
followed by a number.
At this point, you can see that the various windows in the IDE are beginning to show their purposes, and you should take a brief look at them now before you come back to the Try It Out exercise. Note that if any of these windows are not visible on your screen, you can use the View menu to show them. Also, if you do not like the location of any particular window, you can move it by clicking its title bar (the blue bar at the top) and dragging it to a new location. The windows in the IDE can float (stand out on their own) or be docked (as they appear in Figure 8 ). The following list introduces the most common windows:
Next you’ll give your form a name and set a few properties for it.
1. Change the name of your form to something more indicative of what your application is.
Click Form1.vb in the Solution Explorer window. Then, in the Properties window, change the
File Name property from Form1.vb to HelloUser.vb and press Enter, as shown in Figure 1-9.
When changing properties you must either press Enter or click on another property for it to
take effect.
2. Note that the form’s file name has also been updated in the Solution Explorer to read
HelloUser.vb.
3. Click the form displayed in the Design window. The Properties window will change to
display the form’s Form properties (instead of the File properties, which you have just been
looking at). You will notice that the Properties window is dramatically different. The difference
is the result of two different views of the same file. When the form name is highlighted in
the Solution Explorer window, the physical file properties of the form are displayed. When the
form in the Design window is highlighted, the visual properties and logical properties of
the form are displayed.
The Properties window allows you to set a control’s properties easily. Properties are a
particular object’s set of internal data; they usually describe appearance or behavior. In
Figure 1-10 you can see that properties are displayed alphabetically. The properties can also
be grouped together in categories — Accessibility, Appearance, Behavior, Data, Design,
Focus, Layout, Misc, and Window Style.
This is not very descriptive, so change it to reflect the purpose of this application. Locate the
Text property in the Properties window. Change the Text property’s value to Hello from
Visual Basic 2008 and press Enter. Note that the form’s title has been updated to reflect the
change.
If you have trouble finding properties, click the little AZ icon on the toolbar toward the top of the
Properties window. This changes the property listing from being ordered by category to being
ordered by name.
5. You are now finished with the procedure. Click the Start button on the Visual Studio 2008
toolbar (the green triangle) to run the application. As you work through the book, whenever
we say “run the project” or “start the project,” just click the Start button. An empty window
with the title Hello from Visual Basic 2008 is displayed.
--------------------------------------------------
That was simple, but your little application isn ’ t doing much at the moment. Let ’ s make it a little more interactive. To do this, you are going to add some controls — a label, a text box, and two buttons to the form. This will let you see how the Toolbox makes adding functionality quite simple. You may be wondering at this point when you will actually look at some code. Soon! The great thing about Visual Basic 2008 is that you can develop a fair amount of your application without writing any code. Sure, the code is still there, behind the scenes, but, as you will see, Visual Basic 2008 writes a lot of it for you.
No comments:
Post a Comment