Command Button control

CommandButton is simply a clickable button. It is of no use unless you provide an event-handler procedure to execute when the button is clicked. Figure 17-7 shows a dialog box with a few CommandButtons. Two of these buttons feature a clipart image (specified by copying the clipart and then pasting it into the Picture field in the Properties window).

Figure 17-7:

Command Button controls.

Figure 17-7:

Command Button controls.

When a CommandButton is clicked, it executes a macro with a name that consists of the CommandButton's name, an underscore, and the word Click. For example, if a command button is named MyButton, clicking it executes the macro named MyButton_Click. This macro is stored in the Code window for the UserForm.

The following is a description of some useful CommandButton control properties:

I Cancel: If True, pressing Esc executes the macro attached to the button (only one of the form's buttons should have this option set to True).

I Default: If True, pressing Enter executes the macro attached to the button. (Again: just one button should have this option set to True.)

0 0

Post a comment