Hi, as you can understand from the name, I am new in VB. So I have 2 questions regarding buttons:
1:
I have an array of buttons created like this in the code:
Dim buttons(10) As System.Windows.Forms.Button
I need whenever each one of these buttons is clicked to invoke the same method. Then I will go into the method, figure out which button was clicked and act accordingly. The reason I am doing this is because the length of the array will be created dynamically. So I don't know how many buttons there will be when the form loads, but I want when one of the buttons is clicked to call the same method
And 2:
I have written this code:
Dim button As System.Windows.Forms.Button = New System.Windows.Forms.Button()
Private Sub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
End Sub
And I get the error:
Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
Then I change it to this:
Friend WithEvents button As System.Windows.Forms.Button
Private Sub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
End Sub
And when I run it I get a NullReferenceException