• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Getting Data from Visio Draw... > Iterating Through an Object Collecti...

Iterating Through an Object Collection

By now you have learned that you can use the Item property of any collection object to retrieve a reference to any item within the collection by either name or index number. You can iterate through the subject collection to perform the same operation on every member of the collection or test each member of the collection for a required validity and then, and only then, perform that action on that current item within the collection. Iteration is usually performed with a For-Next loop or a Do-While loop. IF statements are often triggers within these loops.

Most Visio collection objects are indexed at 1; that is, their member count begins with 1 and continues up to the value established with the Count property. The Count property returns the number of object items within the collection. Remember that the count that you retrieve is static. When you use the Count property, you obtain a number. If, after retrieving that value, you add or remove items from that collection, your Count number and the actual count no longer match. Should you then attempt to perform some action on each and every member of the collection, you may have unexpected, and maybe even application-crashing, results.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint