Adding the Option Buttons

In this section, you add three OptionButtons to the dialog box. Before adding the OptionButtons, you add a Frame object that contains the OptionButtons. The Frame isn't necessary, but it makes the dialog box look better.

1. In the toolbox, click the Frame tool and drag in the dialog box.

This creates a frame to hold the options buttons.

2. Use the Properties window to change the frame's caption to Options.

3. In the Toolbox, click the OptionButton tool and drag in the dialog box (within the Frame).

This creates an OptionButton control.

4. Select the OptionButton and use the Properties window to change the following properties:

Property Change To

Name OptionUpper

Caption Upper Case

Accelerator U Value True

Setting the Value property to True makes this OptionButton the default.

5. Add another OptionButton and use the Properties window to change the following properties:

Property Change To

Name OptionLower

Caption Lower Case

Accelerator L

6. Add a third OptionButton and use the Properties window to change the following properties:

Property Change To

Name OptionProper

Caption Proper Case

Accelerator P

7. Adjust the size and position of the OptionButtons, Frame, and dialog box.

Your UserForm should look something like Figure 16-6.

The Accelerator property determines which letter in the caption is underlined. For example, you can select the Lower Case option by pressing Alt+L because the L is underlined.

Figure 16-6:

This is the UserForm after adding three Option Button controls inside a Frame control.

Figure 16-6:

This is the UserForm after adding three Option Button controls inside a Frame control.

You may wonder why the OptionButtons have accelerator keys but the CommandButtons go without. Generally, OK and Cancel buttons never have accelerator keys because they can be accessed from the keyboard. Pressing Enter is equivalent to clicking OK because the control's Default property is True. Pressing Esc is equivalent to clicking Cancel, because the control's Cancel property is True.

0 0

Post a comment