WithEvents

Ariez

Well-known member
Joined
Feb 28, 2003
Messages
164
Im not declaring the ComUnitClass like
[VB]
Dim WithEvents whatEver as ComUnitClass
[/VB]

I add and remove these objects from an arrayList like this:
[VB]
ComList.Add(New ComUnitClass())
[/VB]
BUT i need ComUnitClass to raise events so where do i mention the WithEvents?
 
Last edited by a moderator:
Youll probably need a member variable with events in the surrounding class.

Code:
Private With Events mComUnit as ComUnitClass

... 

mComUnitClass = new ComUnitClass()
ComList.Add (mComUnitClass)
 
No public variable declared withEvents==> cant catch its event anyways...
So bad question. sorry...:-\
 
Last edited by a moderator:
You should do something like that:

Code:
dim myUnit as new ComUnitClass()
AddHandler myUnit.myEvent, addressof me.MyUnit_myEventHandler
ComList.Add(myUnit)

Add an "AddHandler" line for each event you want to listen
 
How do you expect to catch an objects event without even having a reference to the object? The point is you cannot, as the two gentlemen above have pointed out through their examples.
 
I already said it was a bad question derek, no need to reopen the wound....

I wish i had that kind of interest on my databinding question!
 
Back
Top