Change this like this:
vb Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim button As New Button
button.Text = "Button"
Me.Controls.Add(button)
AddHandler button.Click, AddressOf button_click
End Sub
Private Sub button_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MsgBox ("It works!")
End Sub
If you add controls dynamically (from the code). You should add handlers like I showed you. If you added your button to your form (it is added with WithEvents keyword) then you should use Handles keyword (look at the form_load sub and how it ends 'Handles Me.Load'