I know in VB.Net there isn't an Index property on the Button control like it does in VB6. But I am trying to replicate a control array in VB.Net. I have created an array of buttons:
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim but(10) As Button Dim i As Integer Dim lngTop As Long = 10 For i = 1 To 6 but(i) = New Button() With but(i) Me.Controls.Add(but(i)) .BackColor = Color.AliceBlue .FlatStyle = FlatStyle.Standard .Text = "But(" & i & ")" .Name = "Button" .Left = 10 .Top = lngTop .Tag = "UP" lngTop = (lngTop + but(i).Height) - 1.5 .Visible = True AddHandler but(i).Click, AddressOf ButtonClick End With Next i End Sub
But my question how do I pass the Button Array index to the following Sub:
VB Code:
Private Sub ButtonClick(ByVal sender As Object, ByVal e As EventArgs) 'Do something with Button End Sub
Thanks,




Reply With Quote