![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
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!
Setting The Remaining PropertiesThe last part of creating the projects visual interface is setting the properties of the controls. Start by selecting the Frame, then scroll the Properties list to bring its Caption property into view. Double-click on the Caption property name, type Text Colors, and press Enter. (This is the very same method you used to set the Text property for the Text Box, remember?) Visual Basic maintains as much consistency as possible in the techniques for dealing with properties, which makes the learning process move as quickly as possible.
Next, select the top Option Button. Set its Name property to optBlack and its Caption property to Blac&k. Thats not a typoan ampersand goes before the k. Whats that for? And what is the Name property? If you place an ampersand in a controls Caption property, the ampersand does not display on the form, but it causes the following letterin this case, the kto be underlined. This defines an access key for the control. When the program is running, the user can select the control by pressing Alt+letter, and the effect will be the same as clicking on the control. Because some people prefer to use the keyboard rather than the mouse, its wise to provide keyboard alternatives for as many program tasks as possible. Access keys are one way to do this. A controls Name property is used to refer to the control in Basic code. While all controls are given a default name when you create them, assigning names that reflect both the type of control and its specific function is a good idea. Thus, the name optBlack identifies an Option Button that sets the Black option. Note that we did not change the default names of the Text Box or the Frame controls. We will not need to refer to the Frame in code, so its Name property is irrelevant. With only one Text Box in the project and no chance of confusion, its default name of Text1 will be okay. We need to change one more property for this Option Button control. Scroll the Properties list to display the Value property, click on it, and then click on the down arrow in the right column. Youll see two possible values for this propertyTrue and Falsecorresponding to on and off states for the Option Button. The default value is False, but we want to set this one to True.
Change the properties for the remaining two Option Buttons as follows: Second Option Button
Third Option Button
Well leave the Value property at False for these two buttons. We really have no choice here, because weve already set the Value property of the first Option Button in this group (optBlack) to True, and only one button in a group can be on at a time. If you did set the Value property of one of the other buttons to True, the Value property of the optBlack button would automatically switch to False. We also need to change the ForeColor property of the second and third Option Buttons. This property sets the color of the controls caption text (the first Option Button will be left at its default ForeColor property of black). Scroll down to the ForeColor property. Youll see a property value that is a weird-looking combination of letters and numbers, something like this: &H80000012& What kind of color is this? Actually, its a number that represents a colorin this case, black. The leading &H identifies it as a hexadecimal number, and the trailing & indicates that its a type Long number. If you dont know what Im talking about here, dont fret; youll learn about these things in Chapter 4. But why does Visual Basic use a number to represent a color? Couldnt it have used something easier to work with, like a color name or a sample of the color? I agree that the numbers are uselessand fortunately, you dont need to work with them directly. If you select the ForeColor property and click on the down arrow in the property value column, Visual Basic displays a small dialog box. Click the Palette tab if necessary to display a palette of the available colors, as shown in Figure 3.7. Select a shade of Blue for the optBlue button and a shade of red for the optRed button. The final properties you need to set are for the three Command Buttons. Im sure by now youre well acquainted with the process of setting properties, so I wont repeat the steps. Here are the properties to set:
Upper Command Button
Middle Command Button
Lower Command Button
|
![]() |
Products | Contact Us | About Us | Privacy |&nbs |