RAJAQ
12/2/2016 - 10:47 AM

Nested Loop > for understanding > this statement doesn't perform any action > we need to construct further statement to perform some action

Nested Loop > for understanding > this statement doesn't perform any action > we need to construct further statement to perform some action based on the loop. >>>> Explanation: The next example uses nested For-Next loops to initialize a three-dimensional array with the value 100. This routine executes the statement in the middle of all the loops (the assignment statement) 1,000 times (10 * 10 * 10), each time with a different combination of values for i, j, and k:

Sub NestedLoops()
    
    Dim MyArray(10, 10, 10)
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
        
        For i = 1 To 10
            For j = 1 To 10
                For k = 1 To 10
                    MyArray(i, j, k) = 100
                Next k
            Next j
        Next i
        
'Other statements go here
End Sub