Is it possible to make an array of and object (like in VB6) such as
Button(1).text="Hello"
Button(2).text="hello2"
you could do it in vb6 by simply copying and pasting an object and it would allow you to decide if you wanted it an array or not.
Printable View
Is it possible to make an array of and object (like in VB6) such as
Button(1).text="Hello"
Button(2).text="hello2"
you could do it in vb6 by simply copying and pasting an object and it would allow you to decide if you wanted it an array or not.
No, .NET doesn't allow for control arrays. What you can do, however, is create a standard event that handles the click event for a number of buttons. For example:
Private Sub ButtonClick_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
Dim oButton as Button
oButton = sender
Select Case oButton.Name
Case "Button1"
Case "Button2"
Case "Button3"
End Select
End Sub
This seems to work pretty well. Hope it helps!
the way you use controls array is though collections