Associating a Delegate with an Class Event...help!!

smcgowan

New member
Joined
Jul 13, 2006
Messages
1
Programming Experience
Beginner
Hi there,

I'm a VB 6.0 starting out in VB.NET. I'm adapting some C# code to VB.NET. I'm creating a delegate. I've created the delegate signature and a variable instance of it. Now I want to associate the delegate with a class event. Can somebody show me how this is written in VB.NET??

Cheers,
Sean
 
So am i right in saying that you have this...

VB.NET:
Public Delegate Sub MyEvent(byval sender as object, ByVal e as SomeEventArgs)

And you want to make an event out of this delegate?


VB.NET:
Public Event RaiseMyEvent as Myevent

VB.NET:
Sub PleaseRaiseMyEvent
 
RaiseEvent(me, New SomeEventArgs)
 
End Sub

Then any instance of this class that is declared with the
WithEvents Keyword i.e
VB.NET:
Public WithEvents _MyDelegateClass As New MyDelegateClass

Can then catch the event that was raised from within that class.
 
Back
Top