473,396 Members | 2,017 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.

Convert C# to VB.Adding Eventhandler.

I have this piece of code I am trying to convert from c# to vb.net.
It's a Windows project.

This line gives me trouble ( I have tried to compress the code for
readability. Hope I haven't screwed up):
m_CA.AnEvent += new U.U_EventHandler(evt);

I assume this is a c# way of adding an additional eventhandler to an event?

If I move this over to VB, I get an error at "AnEvent", and at "evt"
The AnEvent error is "....Can't call directly. Use RaiseEvent...".
The evt error is "....use addressof..."

I don't know if the following information is useful.
At the top of the code is
private U.CC m_CA = null;

and then there is a sub with
m_CA = new U.CC();
m_CA.AnEvent += new U.U_EventHandler(evt);

And then there is this sub
private void evt(byte id, string data){......}

somewhere inside U is
public virtual event U_EventHandler AnEvent;

tia
/jim
Feb 21 '07 #1
2 2651
On 21 Feb, 12:47, "Jim Andersen" <nos...@nospam.dkwrote:
I have this piece of code I am trying to convert from c# to vb.net.
It's a Windows project.

This line gives me trouble ( I have tried to compress the code for
readability. Hope I haven't screwed up):
m_CA.AnEvent += new U.U_EventHandler(evt);

I assume this is a c# way of adding an additional eventhandler to an event?

If I move this over to VB, I get an error at "AnEvent", and at "evt"
The AnEvent error is "....Can't call directly. Use RaiseEvent...".
The evt error is "....use addressof..."

I don't know if the following information is useful.
At the top of the code is
private U.CC m_CA = null;

and then there is a sub with
m_CA = new U.CC();
m_CA.AnEvent += new U.U_EventHandler(evt);

And then there is this sub
private void evt(byte id, string data){......}

somewhere inside U is
public virtual event U_EventHandler AnEvent;

tia
/jim
Hi

Something like "AddHandler m_CA.AnEvent, AddressOf evt" ?

Feb 21 '07 #2
"Jim Andersen" <no****@nospam.dkschrieb:
>I have this piece of code I am trying to convert from c# to vb.net.
It's a Windows project.

This line gives me trouble ( I have tried to compress the code for
readability. Hope I haven't screwed up):
m_CA.AnEvent += new U.U_EventHandler(evt);
\\\
AddHandler m_CA.AnEvent, AddressOf evt
///
I assume this is a c# way of adding an additional eventhandler to an
event?
'AddHandler'/'RemoveHandler' are supported by VB and work pretty similar.
In addition, VB supports 'WithEvent' declarations of type-level variables.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 21 '07 #3

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

Similar topics

6
by: juli | last post by:
I declared: public delegate void PaintEventHandler(object objSender,PaintEventArgs pea); and this.Paint+=new PaintEventHandler(MyPaintHandler); and the: static void MyPaintHandler(object...
3
by: steve | last post by:
Hi all If I add multiple references to the SAME delegate in an event object.. How many references are stored in the delegate list managed by the object. eg. if I .. SomeObject.SomeEvent...
2
by: Tim Marsden | last post by:
Hi, This is what I am doing, please comment if this is the correct way. I need to add controls to a form dynamically. Within the Page_Load event (is not Postback) I run a routine to create the...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
6
by: Just Me | last post by:
I need to create a library sub that adds event handlers to a control. Public Shared Sub AddEvent(ByVal qq As Control, By?? ControlMouseMove As ??) So I need to pass the address of the handler or...
3
by: Bruce Wood | last post by:
Maybe I'm going nuts, but I was so sure that adding the same method more than once to a delegate would result in only one entry on the delegate's call list: this.UpdateEnd += new...
3
by: steve | last post by:
Hi all, I want to be able to hirearchally define event delegate (declarations) WITHIN interfaces. Unfortunatelly C# 1 doesn't appear to support it. How does the following look as a...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
2
by: Jim Andersen | last post by:
I have this piece of code I am trying to convert from c# to vb.net. It's a Windows project. This line gives me trouble ( I have tried to compress the code for readability. Hope I haven't screwed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.