Im trying to write a program in VB.net for a shopping system. It will read through the database and populate the items on the form. The app displays information such as product name etc in labels, inside a scrollable panel. Im creating the objects and assigning values such as text at runtime. I’m using a loop for the code.
If i was using vb 6, i would have a control array, and use the index and my counter to display the data. Since im doing this in vb.net, i have no way to do that.. Any solutions?
VB.NET does not support control arrays, in the same sense as VB6. You can do similar things, though. For instance, if you want to handle events from multiple controls with the same method, you can do so like this:
If you want to create an array of controls that you can loop through, you can do that to, like this:
Alternatively, if you name your controls consistently, you can find them by name in your form’s
Controlscollection. For instance, if you had three text boxes namedTextBox1,TextBox2, andTextBox3, you could loop through them like this: