Converting c# eventhandler code to vb.net

2019-01-09 19:51发布

问题:

What would be equivalent code in vb.net for the code below

dacServices.Message += new EventHandler<DacMessageEventArgs>(dbServices_Message);

回答1:

AddHandler dacServices.Message, AddressOf dbServices_Message

Most of converters do not work because you don't write new EventHandler in vb.net.

But you can see an example here: http://msdn.microsoft.com/en-us/library/ms743596.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

and for regular code conversion I use this converter: http://www.developerfusion.com/tools/convert/csharp-to-vb/