View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Reset All Command Buttons on an Excel UserForm

By toggle buttons do you mean radio buttons?

No I meant "ToggleButton" controls. These can look like CommandButtons but
they can be raised or depressed, as reflected or changed by the Value
property (which fires its click event). By default they do not work like
radio buttons (OptionButtons) though with a little more code they can be
made to do so.

Put two ToggleButton's on the form, run the form and repeatedly click the
form to toggle all of them

Private Sub ToggleButton1_Click()
If Me.ToggleButton1.Value Then
' do depressed state stuff
Else
' do raised state stuff
End If
End Sub

Private Sub UserForm_Click()
Dim ctrl As MSForms.Control
Static bVal As Boolean

bVal = Not bVal
For Each ctrl In Me.Controls
If TypeName(ctrl) = "ToggleButton" Then
ctrl.Value = bVal
End If
Next
End Sub

Regards,
Peter T


wrote in message
...
Peter,

By toggle buttons do you mean radio buttons?

The reason for commandbuttons is that the HMI is a touchscreen with
data being entered by personnel wearing gloves (sometimes). We
initially had radio buttons and check boxes but these proved to be too
small for gloved fingers, hence the reason for the commandbutton
choice.

Please let me know which part of my question you are confused with and
I will try and clarify further.

Thanks,

Glen