Question : c# 2 vb translation

how to write this in VB?
1:
2:
3:
4:
element.Loaded += (s, e) =>
                                  {
                                  ...
                                  }

Answer : c# 2 vb translation

I don't believe this is Linq...  it looks more like an anonymous delegate being (created using a lambda) assigned as an event handler.

It's difficult to tell you how to do this with a straight lambda in VB because we can't see what the lambda is doing from the post above. The simplest workaround I can think of is to declare a sub (event handler) that does what this lambda is doing. Then you can simply use an "AddHanlder" to attach the handler to the event:
1:
2:
3:
4:
5:
6:
7:
Public Sub New()
    AddHandler Me.Load, AddressOf LoadHandler
End Sub

Protected Sub LoadHandler(ByVal sender As Object, ByVal e As EventArgs)
    ' Logic from your post here
End Sub
Random Solutions  
 
programming4us programming4us