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 generic checkbox click form event handler?

Add a class module named Class1 (later name as say clsCBxEvnts)

' code in Class1
' add other events, select cbx from the middle dropdown
' then other events from the right dropdown

Public WithEvents cbx As MSForms.CheckBox
Public tbx As MSForms.TextBox

Private Sub cbx_Change()
tbx.Enabled = cbx.Value
End Sub

''Userform code

' two checkboxes named CheckBox1 & 2
' two textboxes named TextBox1 & 2

Dim arrClsCBoxEvnts(1 To 2) As Class1 ' or say clsCBxEvnts

Private Sub UserForm_Initialize()
Dim i As Long
For i = 1 To 2
Set arrClsCBoxEvnts(i) = New Class1
With arrClsCBoxEvnts(i)
Set .cbx = Me.Controls("CheckBox" & i)
Set .tbx = Me.Controls("TextBox" & i)
.tbx.Enabled = .cbx.Value
End With
Next
End Sub

Regards,
Peter T

"fedude" wrote in message
...
Joel,

Is there a generic form change event that I can catch in a routine that

then
loops through the checkbox controls to see if they've changed?

"Joel" wrote:

Each check box must have a unique function. But all of the routines can

have
one instruction which call a common function.