Below code works as long as the Image Control starts with index 0. It doesn't seem to matter how I want the Image Controls arranged in the grid. It can be 2 x 2, 3 x 3, 4 x 4,.........,5 x 5, 4 x 8, 7 x 10, or any combination of rows and columns.

However, it wont work if The first Image is index 1. The line If n Mod NumberRows only works when I start the For Loop with a 1 but when I start it with a 2 it fails.

Code:
Private Sub ArrangeImages()
 Dim n As Integer
      
 Image1(0).Visible = True
  
 For n = 1 To NumberRows * NumberCols - 1
   If n Mod NumberRows Then
     Image1(n).Left = Image1(n - 1).Left + Image1(n).Width
     Image1(n).Top = Image1(n - 1).Top
     Image1(n).Visible = True
   Else
     Image1(n).Left = Image1(n - NumRows).Left
     Image1(n).Top = Image1(n - NumRows).Top + Image1(n).Height
     Image1(n).Visible = True
   End If
 Next n
End Sub
How can I do the same when the Images are arranged starting with index 1 through last index?

Below doesn't work

Code:
Private Sub ArrangeImages()
 Dim n As Integer
      
 Image1(1).Visible = True
  
 For n = 2 To NumberRows * NumberCols 
   If n Mod NumberRows Then
     Image1(n).Left = Image1(n - 1).Left + Image1(n).Width
     Image1(n).Top = Image1(n - 1).Top
     Image1(n).Visible = True
   Else
     Image1(n).Left = Image1(n - NumRows).Left
     Image1(n).Top = Image1(n - NumRows).Top + Image1(n).Height
     Image1(n).Visible = True
   End If
 Next n
End Sub