Or use the "AddHandler" operator to apply a handler to an event.
[highlight=vb.net]
Dim p As New Panel()
p.Name = "helloJoe"
Me.Controls.Add(p)
AddHandler p.Click, AddressOf myHandler
[/highlight]
And the delegate:
[highlight=vb.net]
Private Sub myHandler(ByVal sender As Object, ByVal e As EventArgs)
Dim sendingPanel As Panel = Ctype(sender, Panel) 'identify which panel sent the event.
MessageBox.Show(String.Format("A panel with name '{0}' triggered this event.", sendingPanel.Name), "Info: Panel was clicked")
End Sub
[/highlight]