Export (0) Print
Expand All
1 out of 6 rated this helpful - Rate this topic

How to: Iterate through a Collection in Visual Basic

You can use a For Each loop to iterate through every element of a collection.

The following example uses the For Each...Next Statement (Visual Basic) to access every item in a collection.

Dim testCollection As New Microsoft.VisualBasic.Collection()
' The collection is empty until you add one or more items to it.
For Each collectionItem As Object In testCollection
    ' Perform desired processing on each item.
Next collectionItem

This example requires:

  • Access to the System namespace.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.