I have an interface class that declares a Public Event.
In my Implementation class, how do I implement that event so that clients of my implementation class can trap events raised?
Printable View
I have an interface class that declares a Public Event.
In my Implementation class, how do I implement that event so that clients of my implementation class can trap events raised?
You don't do anything in an interface. An interface just contains a template that other classes can implement. The "events" are subs/funtions. This is an example
VB Code:
' Interface IBanana Public Sub GotBanana(ByRef pobjBanana As CBanana) ' End Sub Public Sub BadBanana() ' End Sub
and you implement it like this:
VB Code:
' Class CMonkey Implements IBanana Private Sub IBanana_GotBanana(ByRef pobjBanana As CBanana) EatBanana pobjBanana End Sub Private Sub IBanana_BadBanana() ThrowUp End Sub
If on the other hand, by implement you mean raise the event/notification, you do it like this (from a class/module:
VB Code:
' Module MEcosystem ' Throw the event Public Sub GiveHimABanana(ByRef pobjMonkey As CMonkey, _ ByRef pobjBanana As CBanana) ' Reference the class implementing the event, not the interface pobjMonkey.GotBanana pobjBanana End Sub
Congrats on your 666th post BTW :)
VB does not support Events in "inherited" interfaces.
PRB: Error 459 Trying to Use Alternate Object Interface
Thanks for the help people...:)