Learn to program in Visual Basic .NET, the right way

Loops - For/Each

What is a For/Each Loop?

A For/Each loop allows you to repeat an action for each item in a collection.

Iteration

A For/Each loop starts at the beginning of the collectino and will stop once it reaches the end of the collection.

The following demonstrates how to implement a For/Each loop:

Fiddle: Live Demo

Remarks

The For/Each loop is convenient because you do not need to know how many items are in the collection, therefore you do not have know how many times you have to loop for.