AddressOf with parameter

后端 未结 8 669
误落风尘
误落风尘 2021-01-07 23:33

One way or another I need to link groupID (and one other integer) to the button I am dynamically adding.. any ideas?

What I can do;

AddHandler mybutt         


        
8条回答
  •  耶瑟儿~
    2021-01-08 00:16

    There is no way to do this with AddressOf itself. What you're looking for is a lambda expression.

    AddHandler myButton.Click, Function(sender, e) PrintMessage(groupId)
    
    Private Sub PrintMessage(ByVal groupID as Integer)
        MessageBox.Show("Dynamic event happened!" & groupID .tostring)
    End Sub
    

提交回复
热议问题