June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Visual Basic provides the For Each...Next repetition statement for iterating through the values in a data structure, such as an array, without using a loop counter. When used with one-dimensional arrays, For Each...Next behaves like a For...Next statement that iterates through the range of indices from 0 to the value returned by GetUpperBound(0). Instead of a counter, For Each...Next uses a variable to represent the value of each element. The program in Fig. 8.12 uses the For Each...Next statement to determine the minimum value in a one-dimensional array of grades.
1 ' Fig. 8.12: ForEach.vb 2 ' Program uses For Each...Next to find the minimum grade. |
Read now
Unlock full access