Adding Buttons Check Boxes and Other Controls to a Form

After setting the initial properties for a custom form (Name and Caption), proceed with placing the required controls on your form. Here are the step-by-step instructions for how to prepare the form shown in Figure 10-11.

1. Changing the size of the form

When a default form inserted in your project is too small to fit all the controls required by your VBA application, you can change its size in one of the following ways:

a. Sizing the form with the mouse:

■ Click on an empty part of the form. Several selection handles will appear around the form.

■ Position the mouse pointer over the selection handle located on the middle of the right side and drag it to the right to the position you want. Release the mouse button.

■ Position the mouse pointer over the selection handle located on the middle of the bottom and drag the handle down to the position you want. Release the mouse button.

b. Sizing the form using the Properties window:

Each new form has a default size of 180 x 240. The form's dimensions are in points. One point equals 1/72 inch. To change the size of the form, enter new values for the form's two properties: Height and Width.

■ Click in the form's title bar (where the words Info Survey appear).

■ In the Properties window, double-click the Height property and enter the following value: 252.75. Change the Width property to 405.75.

To avoid extra work, always resize the form before adding the desired controls.

2. Adding a frame:

■ Click the Frame control in the Toolbox. The mouse pointer changes to a cross accompanied by the symbol of the selected control.

■ Point to the upper left-hand side of the form. Then click and drag the mouse to draw a small rectangle. When you release the mouse button, you will see a small rectangle titled Frame1. When the frame is selected, various selection handles appear in its sides, and the Properties window's title bar displays Properties—Frame1.

■ In the Properties window, double-click the Caption property and replace the selected default caption Frame1 with Main Interest.

3. Adding option buttons:

■ Click the OptionButton control in the Toolbox. Click the mouse pointer inside the Main Interest frame that you've just added to your form. Click and drag the mouse to the right until you see a rectangle with the default label OptionButton1.

■ In the Properties window, change the option button's Caption property to Hardware.

■ Using the same technique, add another option button to the Main Interest frame and change its Caption property to Software.

The option buttons are used whenever the user has to select one choice from a group of mutually exclusive choices. If the user has to select more than one choice, check boxes are used.

0 0

Post a comment