how do i translate newButton.Click += delegate { window.IsOpen = false; }; in vb.net

后端 未结 2 734
萌比男神i
萌比男神i 2021-01-15 05:07

how do i translate

newButton.Click += delegate { window.IsOpen = false; };

in vb.net

相关标签:
2条回答
  • 2021-01-15 05:34

    How about

    newButton.Click += Function() Do
        window.IsOpen = False
    End Function
    

    This is very helpfull

    Convert C# to VB.NET

    0 讨论(0)
  • 2021-01-15 05:43

    Another one (with VS 2010)

    AddHandler newButton.Click, 
        Sub(s As Object, e As EventArgs)
            window.IsOpen = false
        End Sub
    
    following should also work:
    
    AddHandler newButton.Click, 
        Sub()
            window.IsOpen = false
        End Sub
    

    EDIT: For VS 2008, multi-statement anonymous methods are not possible, so it would be something like

    AddHandler newButton.Click, _
            Function(s As Object, e As EventArgs) window.IsOpen = false
    
    0 讨论(0)
提交回复
热议问题