WithEvents

Ariez

Centurion
Joined
Feb 28, 2003
Messages
164
I'm not declaring the ComUnitClass like
Visual Basic:
Dim WithEvents whatEver as ComUnitClass

I add and remove these objects from an arrayList like this:
Visual Basic:
ComList.Add(New ComUnitClass())
BUT i need ComUnitClass to raise events so where do i mention the WithEvents?
 
Last edited:
You'll probably need a member variable with events in the surrounding class.

Visual Basic:
Private With Events mComUnit as ComUnitClass

... 

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

Visual Basic:
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 object's 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