I want to create an array controllers, that I can control them after they created ..
but i got this error when i click on button 1:
"object reference not set to an instance of an object"
PHP Code:
Dim NewLoc As Integer
Private Btn() As Button
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For i = 0 To 10
NewLoc += 40
Btn(i) = New Button
Btn(i).Location = New Point(10, NewLoc)
Btn(i).Text = i
Me.Controls.Add(Btn(i))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Btn(5).Text = "hi! here is 5"
Btn(7).Text = "hi! here is 7"
End Sub
"object reference not set to an instance of an object"