在声明公共变量的位置加上这句就可以了 Dim WithEvents NewButton As Button
form_load中添加
NewButton = New Button
NewButton.Text = "close"
Me.Controls.Add(NewButton)
调用事件:
Private Sub NewButton_click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles NewButton.Click
MsgBox("not click me!")
End Sub
时间: 2024-10-13 05:36:54