PDA

View Full Version : Visual Basic control arrays


Codered
08-17-2003, 09:59 AM
I recently started programming with visual basic and i can't figure out how arrays work. I want to use a command button control array. Every time i write code for the command buttons click event procedure all the command buttons in the array respond to the event and do what the code says. How do i make only one command button in the array respond to certain code.

Any help would be appreciated a lot.

DNAunion2000
08-17-2003, 12:14 PM
/*DNAunion*/ Just a little piece of advice. I think that control arrays were dropped in VB .NET, so for the sake of future portability, you might want to consider going a different route.

Anyway, what you need to do is to add code to the Click() event handler to determine which of the buttons in the array was clicked and then respond to it specifically. "Pseudo-VB" Code to do that might (and I mean MIGHT) look something like this:


Sub ButtonArray_Click(ByVal Index As Integer)
Select Case Index
Case 0:
' first button in array was clicked...handle it specifically
Case 1:
' second button in array was clicked...handle it specifically
...
End Select
End Sub