nichia
asked on
How to pass a reference of a member of a control array?
Hi Experts:
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
End Sub
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
Exit For
End If
Next
m_Index = c.Index 'Save the index of the currently attached control
Debug.Print "Attached " & oCombo.Name
End Sub
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...
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
End Sub
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
Exit For
End If
Next
m_Index = c.Index 'Save the index of the currently attached control
Debug.Print "Attached " & oCombo.Name
End Sub
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.