- 2,348
- murphykieran
I recently downloaded Visual Basic 2005 Express and I'm trying to reteach myself the basics of Visual Basic.
I had to learn Visual Basic while at college a couple of years ago. It was Visual Basic 6 we used. I remember being able to create an array of controls on a form so that they could by cycled through by using a For-Next loop and simply referring to their index number.
I could have an array of labels and if I wished to cycle through them and put a particular piece of text from a variable array I could just create a loop and stick a line of code like the following into it:
It was easy because I could create a simple one-to-one correspondence between an array of controls and an array of variables.
But I can't do that in Visual Basic 2005 because the ability to create control arrays has been removed and I can't figure out how to do what I want to do.
The program I'm trying to write involves clicking a button which will generate a particular set of numbers in an array and I wish to then display them in a set of labels on the form. The idea of having to refer to each individual label in the code so that I can do something to it instead of being able to simply loop through an array seems ugly and messy.
I assume there's a quick and easy method of doing something similar in Visual Basic 2005, but I can't figure out from the help file what it is. Can anyone give me some help as to how I'd go about doing what I want to do? I hope my request is clear.
KM.
I had to learn Visual Basic while at college a couple of years ago. It was Visual Basic 6 we used. I remember being able to create an array of controls on a form so that they could by cycled through by using a For-Next loop and simply referring to their index number.
I could have an array of labels and if I wished to cycle through them and put a particular piece of text from a variable array I could just create a loop and stick a line of code like the following into it:
Code:
myLabel(x).Text = myArray(x)
But I can't do that in Visual Basic 2005 because the ability to create control arrays has been removed and I can't figure out how to do what I want to do.
The program I'm trying to write involves clicking a button which will generate a particular set of numbers in an array and I wish to then display them in a set of labels on the form. The idea of having to refer to each individual label in the code so that I can do something to it instead of being able to simply loop through an array seems ugly and messy.
I assume there's a quick and easy method of doing something similar in Visual Basic 2005, but I can't figure out from the help file what it is. Can anyone give me some help as to how I'd go about doing what I want to do? I hope my request is clear.
KM.