|
-
May 31st, 2004, 10:02 AM
#1
Thread Starter
Frenzied Member
Control Arrays
I remember being able to create control arrays in VB6... It was pretty easy and made coding a lot less time consuming...
How can I do the same in VB.Net? Is it possible or is this another nifty little feature that M$ left out of .Net???
Thnx,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 31st, 2004, 10:15 AM
#2
Thread Starter
Frenzied Member
Ok... After doing some reading... I guess the control array feature has been taken out of VB.Net... WHY?????? I guess we'll never know.
Anywayz... Here's what I was wanting to use it for...
I have a few constants (Int32) that I use for options in some of my functions.
I wanted to use an array of radio buttons to select the parameters for these functions by using the index of the selected radio button for my constant value.
Is there another way to do this without having to go through a whole lot of if/then or select case statements?
Thanks,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 31st, 2004, 10:21 AM
#3
Thread Starter
Frenzied Member
Ok... So I gave in... Call me weak...
I just created a sub that would setup an array for me to use for my parameters based upon the selected radio button in each group i have...
Oh well.... another workaround, another hour before I have to make another one 
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 31st, 2004, 10:35 AM
#4
A control is just another object and you can still put them into arrays if you want.
VB Code:
Dim ctrls() As RadioButton={RadioButton1,RadioButton2,RadioButton3}
Msgbox (ctrls(1).Text)
-
May 31st, 2004, 10:36 AM
#5
The whole reason for control arrays was that you could have a single event handler for several controls.
In .NET, you can assign several controls to a single handler by adding the control to the Handles clause at the end of the sub.
It's even better than control arrays because now you can have all different types of controls linked to a single handler, instead of just all radio buttons or all textboxes.
As far as your specific problem, there are a few things you could do. You could create a radiobutton subclass that has a property with the constant values. Or maybe there is already a vacant property that you could assign the value to.
Use your imagination.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 31st, 2004, 01:08 PM
#6
Originally posted by crptcblade
The whole reason for control arrays was that you could have a single event handler for several controls. ...
TRUE
Originally posted by crptcblade
Th... In .NET, you can assign several controls to a single handler by adding the control to the Handles clause at the end of the sub ...
Also TRUE, but now you have to list them all by their names instead of single INDEX declaration in the procedure header.
Originally posted by crptcblade
Th... It's even better than control arrays because now you can have all different types of controls linked to a single handler, instead of just all radio buttons or all textboxes ...
What was wrong with Command1_Click 0 ???
It was one very powerfull and convenient feature ...
-
May 31st, 2004, 01:22 PM
#7
Well, you can use Edneeis's suggestion and create an array out of the controls, and reference them that way. That shouse still be legal.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 1st, 2004, 08:47 AM
#8
Thread Starter
Frenzied Member
Thanks guys....
As it turns out, my "workaround" will probably wind up working better for me than using a control array (or some version thereof) with what I'm trying to do...
Isn't it just funny how it works out like that sometimes?
Later,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|