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

Convert C# to VB.Adding Eventhandler.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.