CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Populating a TextBoxArray in VB.Net

  1. #1
    Join Date
    Aug 2010

    Exclamation Populating a TextBoxArray in VB.Net

    I am trying to duplicate the Control Arrays of VB6 in VB.Net.

    For example, on a form, I have 4 Text Boxes; in the ToolBox of VB.Net, there is a TextBoxArray control that I can add to the VB.Net form I am creating.

    How do I populate the TextBoxArray, such as to include in it the 4 Text Boxes I have put on my form such that I can access them programmatically afterwards ?

    I suppose it can be done using the Form Designer, identifying each of the Text Boxes that will be tied to the TextBoxArray, but what is the sequence of actions to get there ? (as far as possible, I want to avoid doing this programmatically).

    Once I know how to operate with a TxtBoxArray, I imagine the sequence will be the same for any other Control Array.

    Thanks for any tip. Azzar

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: Populating a TextBoxArray in VB.Net

    Welcome to the Forums!

    It seems as if you have used the Upgrade Wizard to upgrade your existing VB 6 project to VB.NET.

    Now, because of this you sit with a declaration that looks more or less like this :

    Public WithEvents TextBoxArrayName As Microsoft.VisualBasic.Compatibility.VB6.TextBoxArray
    The _TextBoxArrayName_n are actually normal textbox controls that are added to the array at design time.

    This is not, I repeat not the way to go!

    Do not upgrade your projects!

    In .NET there is no Control Array feature. You can still though, let different controls share the same sub procedure with the Handles clause. .NET deals with Collections, where every object is part of a collection.

    Here is a 3 part article listing all the differences between VB 6 and .NET :

    Comparison Between VB 6.0 and VB.NET Objects, Part 1

    Comparison Between VB 6.0 and VB .NET Objects, Part 2

    Comparison Between VB 6.0 and VB.NET Objects, Part 3

    These are based on VB 2003, but they should in any case apply to whatever version of .NET you have.
    All my Articles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)