FOR EACH LOOP

It repeats a group of statements for each element in a collection. This loop is used for accessing and manipulating all elements in an array or a VB.Net collection.


Syntax:

For Each element [ As datatype ] In group

[ statements ]

Next [ element ]



Example:

Dim anArray() As Integer = {1, 3, 5, 7, 9}

Dim arrayItem As Integer      

For Each arrayItem In anArray

Console.WriteLine(arrayItem)

Next


Last modified: Thursday, 11 July 2019, 11:43 AM