|
-
June 23rd, 2005, 12:41 PM
#1
Control Array and WithEvents Keyword
In my project, I have 2 checkboxes in a control array. I have a class that watches for data modified for each of the controls on a passed in form. The code looks similar to the following:
Code:
Private WithEvents m_chkNewCheckbox1 As CheckBox
Private Sub Command1_Click()
Dim ctl As Control
For Each ctl In Controls
If TypeName(ctl) = "CheckBox" Then
Set m_chkNewCheckbox1 = ctl
End If
Next ctl
m_chkNewCheckbox1.Value = vbChecked
End Sub
Private Sub m_chkNewCheckbox1_Click()
'Do Something
End Sub
I need the WithEvents in order for the rest of the code to work properly, but I keep getting an error (Run-time error '459': Object or class does not support the set of events). If I take WithEvents out, the code works fine (no errors), but then I can't trap stuff like 'm_chkNewCheckbox1_Click', etc.
Is there any way to make the above code work with control arrays?
I'd rather be wakeboarding...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|