ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Button (https://www.excelbanter.com/excel-programming/390862-toggle-button.html)

blackbox via OfficeKB.com

Toggle Button
 
How can I make the caption of the toggle button to change based on wether it
is on or off.

On/Off Yes/No

just something simple like that.

--
Message posted via http://www.officekb.com


NickHK

Toggle Button
 
Whilst I would maybe question the logic of doing this because:
- The idea of the control is that its state is visible from its appearance
- Will the user be confused if they should click it to make if Off, or it
currently is Off. I prefer the CheckBox for clarity.

Ignores the Null state, which you can add if desired.

Private Sub ToggleButton1_Click()

With ToggleButton1
If .Value = True Then
.Caption = "On"
Else
.Caption = "Off"
End If
End With

End Sub

NickHK

"blackbox via OfficeKB.com" <u20390@uwe wrote in message
news:7355a9b84c3b2@uwe...
How can I make the caption of the toggle button to change based on wether

it
is on or off.

On/Off Yes/No

just something simple like that.

--
Message posted via http://www.officekb.com




Incidental

Toggle Button
 
Hi there

you could use something like this

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then
ToggleButton1.Caption = "On"
Else
ToggleButton1.Caption = "Off"
End If

End Sub

Hope this helps



blackbox via OfficeKB.com

Toggle Button
 
Perfect

Thanks!

Incidental wrote:
Hi there

you could use something like this

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then
ToggleButton1.Caption = "On"
Else
ToggleButton1.Caption = "Off"
End If

End Sub

Hope this helps


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1



All times are GMT +1. The time now is 12:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com