Handling events from a control array in VB6
Posted on 2003-11-12
Hi. I'm using VB6. On my main form there is a control array of TextBox's.
I have a class with which I would like to handle the events for this control array. I'm setting up the association in this manner.
---- MyClass Start ----
Private m_editTextArray As Object
Private Sub Class_Initialize()
Set m_editTextArray = fMainForm.editTextArray
---- MyClass End ----
As you can see, I'm assigning the control array object to a member of my class. I cannot handle events on the control array within my class..
Ideally, I'd like to be able to declare my text array, in the class, as:
Private WithEvents m_editTextArray As Object
I could then handle any events through m_editTextArray.
However, the compiler disallows this. I've tried some variations using "As TextBox" (and WithEvents), but am having no luck. I know that I could just declare one TextBox control per index (within my class) from the main form's control array, but that kind of defeats the purpose!
Anyone have an idea on how I can get the events to be fired and handled by my class? Thanks.