PC Review


Reply
Thread Tools Rate Thread

Convert C# to VB.Adding Eventhandler.

 
 
Jim Andersen
Guest
Posts: n/a
 
      21st Feb 2007
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


 
Reply With Quote
 
 
 
 
Pritcham
Guest
Posts: n/a
 
      21st Feb 2007
On 21 Feb, 12:47, "Jim Andersen" <nos...@nospam.dk> wrote:
> 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" ?

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      21st Feb 2007
"Jim Andersen" <(E-Mail Removed)> schrieb:
>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/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert C# to VB.Adding Eventhandler. Jim Andersen Microsoft C# .NET 2 21st Feb 2007 03:19 PM
Adding eventhandler to control Neven Klofutar Microsoft C# .NET 4 2nd Jun 2004 10:41 AM
Adding eventhandler to control Neven Klofutar Microsoft ASP .NET 1 1st Jun 2004 03:44 PM
Adding a eventhandler to control Neven Klofutar Microsoft ASP .NET 0 1st Jun 2004 02:39 PM
cannot implicitly convert type System.EventHandler .NET Terminal882003@yahoo.com Microsoft Dot NET Framework 2 29th Jan 2004 03:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 AM.