Results 1 to 3 of 3

Thread: [RESOLVED] Iterate through several text boxes using loop

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    38

    Resolved [RESOLVED] Iterate through several text boxes using loop

    In Visual Studio 2005, is it possible to assign to an array a set of existing text boxes, then use that array in a loop to sum up the numeric values in the text boxes? I want to do this for specific text boxes, not every text box on the form. Or does this have to be done with a line of code for each text box?
    Thanks.
    Jerry

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Iterate through several text boxes using loop

    Create the array exactly as you would any other array:
    vb.net Code:
    1. Me.textBoxes = New TextBox() {Me.TextBox1, Me.TextBox2, Me.TextBox3}
    Once that's done you can loop through it anywhere you like.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    38

    Thumbs up Re: Iterate through several text boxes using loop

    This works. Thank you. You've added to my skills so that I can manage several or many controls using an array, as with an array of text boxes.
    Jerry

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