473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to read a vb.net event in c#?

Hello, I have a library written in vb.net that I want to use in my c#
project. The library has an event written as:

Public Event KeyPressed(ByVal Character As String, ByVal KeyCode As Integer)

I am trying to wire up this event in my c# class without success. I've
tried the following below, but obviously the method signature doesn't match:

keyboardHandler.KeyPressed += new System.EventHandler(this.HandleKeyPress);

Any ideas?
Nov 16 '05 #1
2 1313
Uhm...

A couple of questions...

Why using or redefining an event that already exists (KeyPressed)?

I think your event definition is not quite correct cuz it looks to a
delegate to me ;-)

Public Event KeyPressed(ByVal Character As String, ByVal KeyCode As Integer)
' Event?! I don't think so...
Delegate Sub MyHandler(sender As Object, e As EventArgs) 'Delegate

My event definition would look like this...

Public Event MyEvent As MyHandler 'Event

In your code you have something like this...

keyboardHandler.KeyPressed += new System.EventHandler(this.HandleKeyPress);

You're using EventHandler Delegate and it doesn't match your event's
definition...

EventHandler Definition is like this...

Public Delegate Sub EventHandler(ByVal Sender As Object, ByVal e As
EventArgs)

it's totally different to yours...

Regards,
--
Angel J. Hernández M.
MCSD

"Frank Rizzo" <no****@nospam.com> escribió en el mensaje
news:eg**************@TK2MSFTNGP09.phx.gbl...
Hello, I have a library written in vb.net that I want to use in my c#
project. The library has an event written as:

Public Event KeyPressed(ByVal Character As String, ByVal KeyCode As
Integer)

I am trying to wire up this event in my c# class without success. I've
tried the following below, but obviously the method signature doesn't
match:

keyboardHandler.KeyPressed += new
System.EventHandler(this.HandleKeyPress);

Any ideas?

Nov 16 '05 #2
Angel J. Hernández wrote:
Uhm...

A couple of questions...
Why using or redefining an event that already exists (KeyPressed)?
This event ain't from a keyboard. I actually figured it out. The
framework creates all the right plumbing behind the scenes when you use
the classic VB syntax. So in C# you can call this as follows:

keyboardHandler.KeyPressed += new
Keyboard.KeyPressedEventHandler(this.HandleKeyPres s);

No mucking with delegates is necessary.
Thanks

I think your event definition is not quite correct cuz it looks to a
delegate to me ;-)

Public Event KeyPressed(ByVal Character As String, ByVal KeyCode As Integer)
' Event?! I don't think so...
Delegate Sub MyHandler(sender As Object, e As EventArgs) 'Delegate

My event definition would look like this...

Public Event MyEvent As MyHandler 'Event

In your code you have something like this...

keyboardHandler.KeyPressed += new System.EventHandler(this.HandleKeyPress);

You're using EventHandler Delegate and it doesn't match your event's
definition...

EventHandler Definition is like this...

Public Delegate Sub EventHandler(ByVal Sender As Object, ByVal e As
EventArgs)

it's totally different to yours...

Regards,

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mike Dole | last post by:
I'm working on a client - server application based on the 'How to Sockets Server and How to Sockets Client' code from the Visual Basic ..NET Resource Kit. Since I want to be able to send 'big...
12
by: francisds | last post by:
Hi, Can you guys see if there's a solution to this problem? I have a database from which I have to read each record and process that record. New records are being added all the time, so I...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
2
by: nekiv90 | last post by:
Greetings, How can 'rows read' from a DB2 CALL statement incur so many reads? I would expect it to be zero. Could someone enlighten me on this? Thanks! Here is output from executing event...
7
by: sergio-p | last post by:
I had no luck in my google search for this answer. Does anyone know if it's possible to read the entries in the Windows Event Log of the server running my PHP page? I'm trying to create an itranet...
8
by: =?Utf-8?B?U3RldmVU?= | last post by:
Under Vista, my program, when reading the system event log, will not show the message saying I don't have the right permission. All I wisht to do is read the event log and show the error messages....
3
by: Mike | last post by:
I know there are server tools out there for this but are admins won't run them on test servers. what I need is a way to read the event view --system for a particular event. I need this to run...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
3
by: cmdolcet69 | last post by:
Im trying to raed data over a com port. The data comes over the serial port as such reading CRLF reading CRLF and so on. The code below only sees the first reading CRLF and then only added that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
0
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
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
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,...

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.