By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

Events in C# generated by VB DLL

P: n/a
I have VB6 DLL that contains a Time class. In the time class a timer event is
defined.

The event is declared as:
Public Event Timer(ByVal sKey As String)

And is called with:
RaiseEvent Timer("somestring")

When I instantiate the Time class in my C# application, the Timer event
shows up as an event inside the class. My question is how do I connect/handle
this event in my C# application.

Any help would be greatly appreciated!
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I have VB6 DLL that contains a Time class. In the time class a timer event
is
defined.

The event is declared as:
Public Event Timer(ByVal sKey As String)

And is called with:
RaiseEvent Timer("somestring")

When I instantiate the Time class in my C# application, the Timer event
shows up as an event inside the class. My question is how do I
connect/handle
this event in my C# application.


If your instance is called _time, then:

_time.Timer += new EventHandler(_time_EventHandler);

Now, EventHandler is the wrong delegate type. You'd have to see what
delegate type got created to match the signature of your VB6 event, and use
the right one.

John Saunders
Jul 21 '05 #2

P: n/a
Understood. Does anyone know how to find the delagate type created for the
VB6 event?

The test delegate I'm now declaring in C#:
public delegate void TimerEventHandler(string sKey);

and then I do the following:
cTmr.Timer += new TimerEventHandler(cTmr_Timer);

When I compile I get the following error:
Cannot implicitly convert type 'myC#.TimerEventHandler' to
'VB6.TimerEventHandler'
"John Saunders" wrote:
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I have VB6 DLL that contains a Time class. In the time class a timer event
is
defined.

The event is declared as:
Public Event Timer(ByVal sKey As String)

And is called with:
RaiseEvent Timer("somestring")

When I instantiate the Time class in my C# application, the Timer event
shows up as an event inside the class. My question is how do I
connect/handle
this event in my C# application.


If your instance is called _time, then:

_time.Timer += new EventHandler(_time_EventHandler);

Now, EventHandler is the wrong delegate type. You'd have to see what
delegate type got created to match the signature of your VB6 event, and use
the right one.

John Saunders

Jul 21 '05 #3

P: n/a
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Understood. Does anyone know how to find the delagate type created for the
VB6 event?

The test delegate I'm now declaring in C#:
public delegate void TimerEventHandler(string sKey);

and then I do the following:
cTmr.Timer += new TimerEventHandler(cTmr_Timer);

When I compile I get the following error:
Cannot implicitly convert type 'myC#.TimerEventHandler' to
'VB6.TimerEventHandler'
This is saying that the correct delegate type is VB6.TimerEventHandler.

John Saunders
"John Saunders" wrote:
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
>I have VB6 DLL that contains a Time class. In the time class a timer
>event
>is
> defined.
>
> The event is declared as:
> Public Event Timer(ByVal sKey As String)
>
> And is called with:
> RaiseEvent Timer("somestring")
>
> When I instantiate the Time class in my C# application, the Timer event
> shows up as an event inside the class. My question is how do I
> connect/handle
> this event in my C# application.


If your instance is called _time, then:

_time.Timer += new EventHandler(_time_EventHandler);

Now, EventHandler is the wrong delegate type. You'd have to see what
delegate type got created to match the signature of your VB6 event, and
use
the right one.

John Saunders

Jul 21 '05 #4

P: n/a

John,

I got it working. Thanks for your help!

"John Saunders" wrote:
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Understood. Does anyone know how to find the delagate type created for the
VB6 event?

The test delegate I'm now declaring in C#:
public delegate void TimerEventHandler(string sKey);

and then I do the following:
cTmr.Timer += new TimerEventHandler(cTmr_Timer);

When I compile I get the following error:
Cannot implicitly convert type 'myC#.TimerEventHandler' to
'VB6.TimerEventHandler'


This is saying that the correct delegate type is VB6.TimerEventHandler.

John Saunders
"John Saunders" wrote:
"Jake Haddock" <Ja*********@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
>I have VB6 DLL that contains a Time class. In the time class a timer
>event
>is
> defined.
>
> The event is declared as:
> Public Event Timer(ByVal sKey As String)
>
> And is called with:
> RaiseEvent Timer("somestring")
>
> When I instantiate the Time class in my C# application, the Timer event
> shows up as an event inside the class. My question is how do I
> connect/handle
> this event in my C# application.

If your instance is called _time, then:

_time.Timer += new EventHandler(_time_EventHandler);

Now, EventHandler is the wrong delegate type. You'd have to see what
delegate type got created to match the signature of your VB6 event, and
use
the right one.

John Saunders


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.