Results 1 to 6 of 6

Thread: Control Arrays

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    85

    Control Arrays

    How can to make control arrays in vb.net ?
    there is no INDEX property or Load method like VB6.
    so how i can do it ?

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Control Arrays

    Control arrays are no longer supported in VB.NET
    Though, you can easily create an equivalent

    Code:
    'declare an array and fill it with elements you want
    Dim myTextBoxes() as TextBox = {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5}
    
    'Then use it like this
    myTextBoxes(2).Text = "whatever"
    Last edited by Pradeep1210; Feb 28th, 2010 at 03:42 AM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: Control Arrays

    Quote Originally Posted by Pradeep1210 View Post
    Control arrays are no longer supported in VB.NET
    Though, you can easily create an equivalent

    Code:
    'declare an array and fill it with elements you want
    Dim myTextBoxes() as TextBox = {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5}
    
    'Then use it like this
    myTextBox(2).Text = "whatever"

    where is the "es" of
    Code:
    myTextBox(2)
    gone pradeep

    If you find my reply helpful , then rate it

  4. #4
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Control Arrays

    hmm.. typo.
    I corrected it on the original post.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    85

    Re: Control Arrays

    Wow !!
    no supported !!

    thanx for this code.

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Control Arrays

    Quote Originally Posted by 3Dmajid View Post
    Wow !!
    no supported !!

    thanx for this code.
    Yes, it is not supported in .net as better ways are available.

    You can create a control dynamically, and you can declare an array of controls too. So there's no need for a control array as was in VB6 and earlier. Though it would have been nice if it were supported.

    Since they were breaking backward compatibility with introduction of .net anyways, they felt better to do away with it.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

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



Click Here to Expand Forum to Full Width