473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Events in C# generated by VB DLL

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
4 1438
"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
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
"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
9706
by: Marek Mand | last post by:
How to use generated keyboard events? What I am trying here to do is in onkeyup event handler http://www.hot.ee/idaliiga/braggart/createEventTest.htm generate a (shift)TAB keydown so the...
8
2237
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
2
2085
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
4
1577
by: JezB | last post by:
I am dynamically creating WebControls and creating them on my page. Some of these are buttons, and I attach events to these buttons. The problem is these force a post-back, so I must regenerate all...
11
1839
by: Nicky Smith | last post by:
Hello, I'm studying a book on VB.net Win apps, and I'm reading a section on events and delegates and raising events. Is it just me, or is this not just subs dressed up as something else? I...
4
2116
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
30
3608
by: Burkhard | last post by:
Hi, I am new to C# (with long year experience in C++) and I am a bit confused by the language construct of events. What is it I can do with events that I cannot do with delegates? At the moment...
1
3495
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
3
2813
by: Jacksondf | last post by:
What is that procedure for determining which events can be binded for a particular widget? The docs don't seem to help. For example, how can I know which events wx.SpinButton will send. Thanks.
5
1201
by: puzzlecracker | last post by:
I am sort of confused here. Jon Skeet allegedly claims that evens are like properties. To me, on the contrary, they look more like instances of delegates. What's the deal here? Thanks
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.