How to pass a reference of a member of a control array?
Posted on 2004-10-08
I need to modify the behavior of a combobox and am using a class module as the helper class. It works fine passing in a single control, but I need to modify it to accept mambers of a control array.
In my form code I have this:
Private oCombo As cComboHelperArray
Private Sub cbArray_GotFocus(Index As Integer)
'Attach the helper class to ComboBox array cbArray in the GotFocus event
oCombo.AttachTo cbArray, Index
And in the Class Module:
Private WithEvents moCombo As ComboBox
Public Sub AttachTo(oCombo As Variant, ByVal Index As Long)
Dim c As Control
'On Error Resume Next
For Each c In oCombo
If (c.Index = Index) And (TypeOf c Is ComboBox) Then
Set moCombo = c '<< Error here 459: Object or Class does not Support the set of events
m_Index = c.Index 'Save the index of the currently attached control
Debug.Print "Attached " & oCombo.Name
See the error 459 noted above. Any ideas how I can set the helper combobox to get the events of the attached combobox array?
Thanks in advance...