INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

TextBox Arrays in Visual Basic.Net

TextBox Arrays in Visual Basic.Net

(OP)
Hello
In VB6 and earlier versions it was possible to have arrays of Textboxes, e.g TextBox(0); TextBox(1) etc
which simplified the display of data from arrays or read from a file.
In Visual Basic.Net this feature doesn't seem to be available and I was wondering if there was any equivalent
way to do the same task without resorting to very extensive coding?

RE: TextBox Arrays in Visual Basic.Net

Well, there is something like that, but a little different smile

Let's say you have 2 option buttons (called here Radio Buttons): radAll and radCoRt (this is from my app, option 'All' and option 'County and Route') and you want to 'treat' them as an array (in CheckedChanged event):

CODE

Private Sub RadioButtons_CheckedChanged(ByVal sender As System.Object, _ 
    ByVal e As System.EventArgs) _
    Handles radCoRt.CheckedChanged, radAll.CheckedChanged

If CType(sender, RadioButton).Checked = False Then Exit Sub

Me.Cursor = Cursors.WaitCursor

Select Case CType(sender, RadioButton).Name
    Case radAll.Name
        ...
    Case radCoRt.Name
       ...
End Select

Me.Cursor = Cursors.Default

End Sub 

The BLUE part of the code may be whatever you want, it is just a name of the procedure. The RED part is what creates an 'array' (not really) of the controls.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: TextBox Arrays in Visual Basic.Net


It's still possible to have an array of not just textboxes, but any type of control. Just define the array as the type of the control, like so:

Dim TextBoxes() As TextBox

You can define the size of the array at creation:

Dim TextBoxes(5) As TextBox

Or you can use ReDim and ReDim Preserve to resize the array as needed at runtime.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: TextBox Arrays in Visual Basic.Net

> Just define the array as the type of the control

That's not quite the same thing. An array of controls is not a control array (the latter being what the OP is asking about)

>this feature doesn't seem to be available

Sadly not. There was talk some years ago that Microsoft would bring the feature to VB.NET, but it never happened.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close