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. One of these buttons features a picture (specified using the Picture property).

Figure 17-7:

Command Button controls.

Figure 17-7:

Command Button controls.

Command Button Example Vba

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:

l Cancel: If True, pressing Esc executes the macro attached to the button. l Default: If True, pressing Enter executes the macro attached to the button.

0 -1

Responses

Post a comment