For each loop in Visual Basic

For each allows you to loop through the items in a set of data.

Example

Module Module1

    Sub Main()

        Dim StringArray2() As String = {"one", "two", "three", "four"}

        For Each a In StringArray2
            Console.WriteLine(a)
        Next

        Console.ReadLine()
    End Sub

End Module

Output

one
two
three
four
Share

You may also like...