Another way in additon to what others have suggested is create a custom
collection instead of an array that will funnel and raise the events
Look up how to create a custom collection class
(
http://visualstudiomagazine.com/feat...orialsid=1329).
That way you could use
Dim WithEvents myCol As New MyCollection
The collection class would look something like this
(not complete)
Public Class MyCollection(Of T)
Inherits System.Collections.CollectionBase
Public Event MySpecialEvent(ByVal sender As Object, ByVal e As
EventArgs)
Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal
value As Object)
AddHandler value.MySpecialEvent, AddressOf HandleMySpecialEvent
MyBase.OnInsertComplete(index, value)
End Sub
Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal
value As Object)
RemoveHandler value.MySpecialEvent, AddressOf HandleMySpecialEvent
MyBase.OnRemoveComplete(index, value)
End Sub
Private Sub HandleMySpecialEvent(ByVal sender As Object, ByVal e As
EventArgs)
'Bubble up the event
RaiseEvent MySpecialEvent(sender, e)
End Sub
End Class
"Guy Cohen" <Gu******@discussions.microsoft.comwrote in message
news:29**********************************@microsof t.com...
Hi all
I googled some and found that I can no longer - dim withevents
myclassname()
I also understand that I can use addhandler...
But... what if I do not know the amount of classes that will be created
?....
What am I trying to do:
I have a process that scans a directory for files tranxxxxx.txt
for each transaction file I want to create a clsTransactionHandler
the class will read the file, process it, store it where it should etc etc
for each class the process needs to know when it is done (to notify the
user)...
Please advise
TIA
Guy Cohen