Results 1 to 4 of 4

Thread: Collection of Controls... what order does For Each follow?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    Collection of Controls... what order does For Each follow?

    It seems that when I loop through the controls on a form using For Each, that they are processed in the reverse order from which they were placed on the form. This seems to be the case even if I change the tab order manually.

    Can anyone confirm this? Can one rely on this sequence always being the case?

    Ciao,
    .

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    I wouldn't go by the order. If I required a specific order I would either use an array or write some routine to sort a collection the way I want.

    Is there a specific reason you want this collection to be ordered a particular way?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Collection of Controls... what order does For Each follow?

    Originally posted by Jim Brown
    It seems that when I loop through the controls on a form using For Each, that they are processed in the reverse order from which they were placed on the form. This seems to be the case even if I change the tab order manually.

    Can anyone confirm this? Can one rely on this sequence always being the case?

    Ciao,

    Hmmm I would agree that it appears to be in reverse order.
    But as you know, you can never assume anything when writing release-edition software
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    Re: Well ...

    Originally posted by honeybee


    Is there a specific reason you want this collection to be ordered a particular way?

    .
    No not really! I just noticed in a debug.print that it seems to be that way and wondered if one could rely on that.

    This reminds me of a situation we had some years back with a proprietary print program. It ran on 2 platforms, a DEC Mini and an IBM mainframe and they built more features in the IBM version on account of having more bang. Most of us knew the differences.

    Bobby had only ever been trained on the m/f version, but one day needed to code on the DEC. He used a feature he had always used on the IBM, and all was well.

    Then one day a new version of the DEC version came out and his code fell over. Turned out the feature he had used on the DEC was a m/f only feature but had worked on the DEC by default or oversight or whatever. When it was taken out, they said it was never there according to the (DEC version) manual, and he shouldn't have used it in the first place.

    Your mileage may vary.
    .

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