473,387 Members | 1,556 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,387 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 1400
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.