Where you declared Dim regularArray(columns, rows) As Integer
, it makes use of the values of columns
and rows
as they were at the time; in this case, they were both zero, and hence regularArray
is a two-dimensional array having one element - namely, regularArray(0, 0)
. Use ReDim
to change the size of its dimensions. E.g., put this just before the Select Case switchOption
:
ReDim regularArray(columns, rows)
See http://msdn.microsoft.com/en-us/library/w8k3cys2.aspx for details.