Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Event-Raising Classes 1

Status
Not open for further replies.

Norris68

IS-IT--Management
Jun 19, 2002
769
GB
I have a class that raises a StateChanged event. It is working fine as a single instance. I would like to have a number of instances of this class and be able to handle the events raised - for instance an array of classes that I could extend (i.e. ReDim). However, as the error message says "'WithEvents' variables cannot be typed as arrays".

Is there any way I can have a dynamic number of instances of this class, or will have to declare the maximum number I think will be used individually?
 
What about using a Collection class as a holder?

Craig
 
Thanks Craig, but I still don't see how I could have an arbitary number of instances while still getting the events, even if I used a collection class. What I would really like to do is:

Private WithEvents MyObjects() As MyObjectType

Private Sub MyObjects_StateChanged(ByVal NewState As MyObjectType.State) Handles MyObjects().StateChanged
End Sub
 
Thanks John - that sounds more like it. I'll have a play later.
 
Works a treat - thanks a lot John! If I could give you more than one star I would...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top