在声明公共变量的位置加上这句就可以了 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
VB 用代码创建的控件和接收事件,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/zuiyeqingfeng/p/3770563.html