Ramachandran
New Member
- Joined
- Oct 17, 2011
- Messages
- 47
I am populating a frame on a form with a number of checkboxes:
The frame is populated fine.
However I want individual click events for each of the chkBox'es.
Best case:
One clever multi event handler
or perhaps use some userform event:
Worst case:
I could create thousands single event handlers.
Any suggestions?
Userform_initialize()
...
Dim cB As MSForms.CheckBox
For i = 1 To dX
For j = 1 To dY
idx = j + (((i - 1) *dY))
Set cB = Frame2.Controls.Add("Forms.CheckBox.1", "chkBox" & idx)
With cB
.width = 50
.Height = 16
.Left = 6 + (54 * (j - 1))
.Top = 17 + (19 * (i - 1))
.Visible = True
End With
Next j
Next i
The frame is populated fine.
However I want individual click events for each of the chkBox'es.
Best case:
One clever multi event handler
private sub chkBoxClick(boxNumber as integer)
'Do stuff
end sub
or perhaps use some userform event:
private sub Userform_Clack()
If Left(me.activecontrol.name, 6).value = "chkBox' then...
end sub
Worst case:
I could create thousands single event handlers.
I can't even find a way to this...private sub chkBox173_Click()
Call LotsOfFun(173)
end sub
Any suggestions?