Microsoft Office Tutorials and References
In Depth Information
The Click and DblClick events occur when the user clicks or double-clicks the mouse. In some
cases, the Change event might also fire if clicking or double-clicking the control affects the
control’s Va flue .
The Label Control
The Label control allows your program to display text on the form that the user can’t modify.
Ty pically, the Label control is used to describe the contents of other controls, such as the
Te xtBox control.
Although the user cannot change the value of a Label control, your program can, by assigning
a value to the Caption property. Unlike many other controls, the Label control doesn’t have a
Va flue property because there’s nothing the user can change. However, the Label control will
respond to mouse clicks, triggering either the Click or the DblClick event.
The CommandButton Control
The CommandButton control displays a button that, when clicked, triggers the Click event
associated with the control. Another way to trigger a command button is to use the Tab key
to shift the focus to the command button and then press the Enter key or the Spacebar.
The following routine changes the text displayed on the button each time the button is
clicked. So if the Caption property reads “Off ”, the routine will reset the value to “On”; oth
erwise, the Caption property will be set to “Off ”.
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Off" Then
CommandButton1.Caption = "On"
CommandButton1.Caption = "Off"