Events

N

Nikolay Petrov

Let's say I have a class, which raises events:

Class eventRaiser
Public Event Event1()
Private WithEvents timer1 As System.Timers.Timer
Public Sub New()
With timer1
.Interval = 2000
.Enabled = True
End With
End Sub
Private Sub timer1_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles timer1.Elapsed
RaiseEvent Event1()
End Sub
End Class


Then In my app I declare variable with of type this class and then add
handler for the event. This work's fine.
I need a way to handle events from a collection of my class. Like if I
add many instances of my class in ArrayList or similiar.
How to handle the events raised from different classes in the
colletion?
Also the IDE doesn't allow me to declare a variable with "WithEvents"
in a procedure, only on class level.
 
N

Nikolay Petrov

Ok, Cor I know this. But how to add handler for an item, which raised
events, if this item is in collection, like ArrayList or similiar?
 
C

Cor Ligthert [MVP]

Nikolay,

How can an item raise an event and why would it do that.

An item an be the reason for a call of a method

If Item = "Nicolay" then help("I don't undrstand what he means")

Therefore give some sample code?

Cor
 
N

Nikolay Petrov

No offence, but I don't see what you don't understand Cor.
I've found what I was looking for.
Thanks however.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top