Results 1 to 3 of 3

Thread: How to Loop through controls

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    83

    How to Loop through controls

    Hi,

    I can't use the normal method, my controls (picture boxes) names contain numbers such as 00, 01, 02 etc which corrispond to my multidimenional array.

    I'm attempting change the picturebox's values in a for loop via the counter in the loop, for example:

    Code:
    For i = 1 To 4
                PictureBox(i).enabled = False 'Picturebox1 will be the first one(counter starts at 1)
            Next
    I basically need to access each one as I would with an array, I can't type the full names out, can only refer to them via their names + counter number because I don't know what control name I would be dealing with at that time in the loop.


    Rep will be provided if can get help, need a easy way to do this.

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

    Re: How to Loop through controls

    If you have a multi-dimensional array then why don't you just loop through that?
    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
    Lively Member
    Join Date
    Aug 2009
    Posts
    83

    Re: How to Loop through controls

    Ty for reply, Edge.



    Quote Originally Posted by jmcilhinney View Post
    If you have a multi-dimensional array then why don't you just loop through that?
    I'm looping through the array but needed to also loop through the picture boxes in that way and I couldn't see another way of doing it. To access a picture box by it's name and number which corrisponds to the counter in the loop.

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