Easily the most popular single topic at About Visual Basic
Whatever Happened to Control Arrays?
Years ago, I received the first of a continuing stream of emails asking this question. The problem is that one of the very popular features of VB6, Control Arrays, disappeared as part of the massive technoquake that is .NET. And a lot of people really miss it! I eventually published seven seperate articles about it. They're all listed in the last one of the series:
VB.NET: What Happened to Control Arrays!!! (Part VII)
I actually thought I had heard the end of this since I haven't received an email about it for several months. But Bruce Gordon, (check out his page The VB Programmer) sent me an email describing his favorite way to accomplish what he describes as a VB.NET 'control array'. His code seems to be a subset of the techniques that have been recommended by others, including Microsoft: Control Arrays for Visual Basic 6.0 Users.
This illustrates a fundamental principal of VB.NET: There are a gazillion ways to do just about anything and what you call it is often a matter of choice. Bruce admits that his technique doesn't satisfy many of Microsoft's definitions (see below) but he wrote that it works well for him.
You can review Bruce's recommendations in his own words here: The Bruce Gordon Control Array
For those who didn't use the VB6 control array, Microsoft's documentation states that they should have these features:
- Iterating Through Controls
VB6 had the ability to iterate through a group of controls using the Index property. For example, to clear the text of all TextBox controls in a control array, you could loop through the control array using the Index property as a loop variable. If Text1 was a TextBox control array, the code would look something like this:
For i = 0 To Text1().UBound
Text1(i).Text = ""
Next - Siting on different Frame controls
Controls in a single control array could be sited on different containers. For example, TextBox controls contained on two different Frame controls could be part of the same control array. - Adding Controls at Run Time
Controls could be added to a control array at run time using the Load statement. - Adding Event Handlers at Run Time
When you added a control to a control array at run time, the new controls events were automatically handled by the events for the control array.
VB6 control arrays were easy to create (Just add a second component with the same name and VB6 would politely ask if you were trying to create a control array.) and oh so very useful. Why couldn't Microsoft have thrown us a bone on this one?


The way I use control arrays in VB6 is to use an Enum for the various values of the Index. This allows me to make the code a bit more readable; unfortunately, it’s awkward to do using the proposed substitute method in VB.NET.
Sigh!
I’ve recently joined and wanted to introduce myself
Can’t find the right place to buy Viagra?
Aware of fraud or poor medications?
Visit Canadian Health&Care Mall and you won’t regret!
High-quality Viagra, Cialis and other medications:
Buy now high quality medications from the superb online pharmacy!
Secure and confidential purchase, instant shipping worldwide!
Hi, I have been also missing the VB6 control arrays. I have read and read and read about the subject but still haven’t found a solution for my problem. I admit I am no professional or even mid-class programmer but I like to make some of my ideas into applications. So: One of the things I did the most in vb6 is:
Having a set of optionbuttons (now named Radiobuttons) and according to which one was pressed, executing an activity, eg:
For i = 1 to 3
if option1(i).Checked = True Then
msgbox(”Option ” & i & ” was selected.”)
next i
I would like to do the same in VS2008 but the huge code I discovered in related articles intimidated me, mostly because I don’t understand what it does. Is there a simpler and clearer solution (code) for my problem?
Thank you
I am here at a forum newcomer. Until I read and deal with the forum.
Let’s learn!
This look interesting,so far.
If there are any real people here looking to network, leave me a post.
Oh, and yes I’m a real person LOL.
Peace,
I’m certainly a real person.
Did you notice that I consolidated all of the “Control Array” articles in a single download?
http://visualbasic.about.com/od/quicktips/qt/ctrlarrsumm.htm
thanks a lot for this