Toggle Button

Use a ToggleButton control to enable an option and leave it that way until the user depresses the button again (see Figure 3-20). This control presents an on/off switch whose appearance changes depending on whether or not it the user has depressed it. The ToggleButton control has a Picture property you could change depending on the state of the button.

In the following example, the condition of the ToggleButton control is tested using a Select ... Case statement and an appropriate message is displayed:

Private Sub ToggleButton1_Click() Select Case ToggleButton1.Value Case False

MsgBox "ToggleButton1 is Off" Case True MsgBox "ToggleButton1 is On" End Select

Figure 3-18. A UserForm with a CheckBox control
Figure 3-19. A UserForm with OptionButtons
Vba Togglebutton Function
Figure 3-20. A UserForm with ToggleButtons

Was this article helpful?

0 0

Post a comment