![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
To save the current project, select Save Project from the File menu, or click on the Save Project button on the toolbar. Youll be prompted for a project name the first time you save it. Once a project name has been assigned, you will not be prompted further.
Drawing Your Way To SuccessWhen Visual Basic first burst onto the scene, the feature that most amazed programmers was the way it allowed them to draw the programs visual interface. No more writing long and complex code statements to display something on screen; just point, click, dragand thats all there was to it. Now that Visual Basic has been around a while and spawned a whole fleet of copycats, the idea of drawing a programs interface has become accepted as the norm. Even so, I still think its fun. In this section, Ill describe the tools and techniques Visual Basic provides for interface design. The controls you can use are represented by buttons in the Visual Basic toolbox. The picture on each button makes an attempt to represent the corresponding control. If youre still not sure, just rest the mouse pointer over the button for a second or two: A tooltip will display next to the mouse pointer, describing the buttons control. I should mention that the controls displayed in the toolbox are only a small subset of what is available to you. When you start working, the default set of controls is displayed; these are called the intrinsic controls. Other controls are displayed in the toolbox only when you specify. Ill explain how later in the chapter. Placing Controls On A FormWhen you start Visual Basic, a new project and a blank form will display in the Project window. Generally, you will just begin working with this form. If you need another blank form, simply select Add Form from the Project menu. While a Visual Basic program can contain multiple forms, we are going to limit ourselves to single-form projects for now. Visual Basic has two methods for placing controls on a form. If you double-click on a button in the toolbox, Visual Basic places a default-size control in the center of the form. This method is certainly quickif you want a default-size control in the middle of your form. Otherwise, youll have to move and size the control after it has been placed on the form. The alternative, and I believe preferable, method is to click on the desired button and then drag to place the control on the form. As you drag, a small window opens showing the current dimensions of the control, its width and height. The units of measurement are twips, Visual Basics default unit of screen measurement. Youll learn more about twips in a later chapter; for now, its enough to know that there are 1,440 twips in an inch. The click-and-drag method has the advantage of letting you place the control and set its position and size in one step, but you can use whichever technique you prefer. If youve placed a control on the form and want to place more controls of the same size and type, you can copy the original. Be sure that the control you want to copy is selected (small handles will appear around the edges of a selected control). If not, click on the control to select it. Then follow these steps:
Every control that you place on a form is given a default set of properties. As we will cover later in this chapter, modifying the properties of controls is a central part of designing your Visual Basic interface. Most importantly, each control is assigned a default Name property in a form that combines the name of the control type and a sequential number. For example, the first Text Box control that you place on a form is assigned the name Text1, the second one is Text2, and so on.
Manipulating The FormThe size and position of a form during program design is the size and position it will have when the final program runs (unless you modify the size or position in code). You can change the relative screen position that the form will have during program execution by pointing at the forms icon in the form layout window at the lower right corner of the Visual Basic screen. When the mouse pointer changes to a four-headed arrow, drag the form icon to the desired screen position. To change the forms size, click on it to select it (be sure to click between any controls that are on the form). The form will display eight handles on its corners and edges indicating that it is selected. Three of the handles will be dark; point at any one of them and drag the form to its new size. As you may have guessed, a forms size and position are properties that can be changed by the programs code when the program executes. Most Visual Basic programmers dont worry about form position during design. If it is necessary to display the window at a specific position when the program runs, it is better done in code. This permits you to take the users screen resolution into account. Size is a different matter. Forms that contain a lot of controlslike most dialog boxeswill have their proper size dictated by their contents. If the form is too small, some of the controls may be hidden, whereas a form that is too large wastes valuable screen space. The usual approach is to adjust the size of the form visually during design, then set the forms BorderStyle property to Fixed Single or Fixed Dialog, so the user will not be able to change its size while the program is running. In other forms where size is not critical, the BorderStyle property is usually left at the default setting of Sizable, so the user can adjust its size while the program is running.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |