Home All Groups Group Topic Archive Search About

Event handling (C# vs VB6.0)

Author
20 Sep 2006 12:29 PM
sandeep.raukutam
I have the following code in C# to "sink" an event with an event
handler.

Obj.OnCallEvent +=new CallEventHandler(obj_OnCallEvent);

obj_OnCallEvent being the actual method and "obj.OnCallEvent" is the
actual event.

This events are provided by a 3rd party Dll.

I have converted that dll into a type library and used it in VB6.0

However, I'm not sure how to "sink" events in VB6.0!

Please advise what would be a compatible statement in VB6.0 for above
C# code?

Author
20 Sep 2006 12:07 PM
Cowboy (Gregory A. Beamer)
If you have it wrapped properly, you are most of the way there. In the
object declaration, add with Events (Dim with Events objectName as
TypeofWrapper). It is then a matter of matching the interface. You should
see the events on the COM wrapper and be able to bind to them.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
<sandeep.rauku***@gmail.com> wrote in message
Show quote
news:1158755384.784935.3400@m73g2000cwd.googlegroups.com...
>I have the following code in C# to "sink" an event with an event
> handler.
>
> Obj.OnCallEvent +=new CallEventHandler(obj_OnCallEvent);
>
> obj_OnCallEvent being the actual method and "obj.OnCallEvent" is the
> actual event.
>
> This events are provided by a 3rd party Dll.
>
> I have converted that dll into a type library and used it in VB6.0
>
> However, I'm not sure how to "sink" events in VB6.0!
>
> Please advise what would be a compatible statement in VB6.0 for above
> C# code?
>
Author
20 Sep 2006 12:45 PM
Damien
sandeep.rauku***@gmail.com wrote:
Show quote
> I have the following code in C# to "sink" an event with an event
> handler.
>
> Obj.OnCallEvent +=new CallEventHandler(obj_OnCallEvent);
>
> obj_OnCallEvent being the actual method and "obj.OnCallEvent" is the
> actual event.
>
> This events are provided by a 3rd party Dll.
>
> I have converted that dll into a type library and used it in VB6.0
>
> However, I'm not sure how to "sink" events in VB6.0!
>
> Please advise what would be a compatible statement in VB6.0 for above
> C# code?

You'll need to have a class or form level variable declare WithEvents
(e.g. Dim WithEvents Obj as TargetObject). You'll then be able to write
a function called Obj_OnCallEvent (or similar) which handles the event.
This is assuming that the event is one that VB can hook up to - e.g.
that it is declared in a COM interface as an event (IIRC).

Damien

AddThis Social Bookmark Button