NNC in grids: Declaring counter variable outside the loop due to MS Visual C compiler incompatability