'-- In the form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim btn As New Button()
With btn
.Size = New Size(90, 40)
.Location = New Point(15, 15)
.Text = "Testing 1 2 3"
'causes the newbtnClick procedure to fire on the click event.
AddHandler btn.Click, AddressOf newbtnClick
End With
Me.Controls.Add(btn)
End Sub
Private Sub newbtnClick(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("You clicked the button!")
End Sub