vinu natesh vinu natesh - 1 month ago 9
Vb.net Question

Lambda Event Handler in C# - VB.NET Equivalent

I need to convert the following code from C# to VB.NET.

lnkSynEvent.Click +=
new EventHandler((s,e)=>lnkSynEvent_Click(s, e, your_parameter));


Here lnkSynEvent is the id of button. Any Help is appreciated.

Answer

It can be used like this:

AddHandler lnkSynEvent.Click , Sub(s, ea) lnkSynEvent_Click(s, ea, your_parameter)

Or this:

AddHandler lnkSynEvent.Click , Sub(s, ea)
                                   lnkSynEvent_Click(s, ea, your_parameter)
                               End Sub

Note

  • Pay attention, you should have a lnkSynEvent_Click accepting 3 parameters of consistent types which you are trying to pass to it.

  • Usually you can trust the out put of online code converters, but you should have enough knowledge and know syntax yourself enough to be able to change some part of converted codes.

  • For more description and example take a look at Lambda Expressions (Visual Basic).

Comments