06-20-2024, 05:16 PM
(06-20-2024, 05:10 PM)bplus Wrote:Quote:And I's brokes it already!
reread my reply 13, expansion only
Code: (Select All)
REDIM Grid(1 TO 5, 1 TO 5) AS LONG
' LoadInitialValues
FOR y = 1 TO 5
FOR x = 1 TO 5
counter = counter + 1
Grid(x, y) = counter
NEXT
NEXT
ShowArrayValues Grid()
moreXPerRow Grid(), 4, 10
ShowArrayValues Grid()
END
SUB moreXPerRow (arr() AS LONG, xpr AS LONG, r AS LONG) ' xpr x per row
DIM AS LONG lbx, lby, ubx, uby
lbx = LBOUND(arr, 1)
lby = LBOUND(arr, 2)
ubx = UBOUND(arr, 1)
uby = UBOUND(arr, 2)
DIM c(lbx TO ubx, lby TO uby) AS LONG
FOR y = lby TO uby
FOR x = lbx TO uby
c(x, y) = arr(x, y)
NEXT
NEXT
REDIM arr(xpr, r) ' fixed
'ReDim _Preserve arr(xpr, r) 'nope
'ReDim _Preserve arr(lbx To xpr, lby To r)
'ReDim _Preserve arr(lbx To xpr, lby To r) As Long ' nope
FOR y = lby TO uby
FOR x = lbx TO uby
IF x <= xpr THEN arr(x, y) = c(x, y)
NEXT
NEXT
END SUB
SUB ShowArrayValues (arr() AS LONG)
PRINT "Array Values:": PRINT
FOR y = 1 TO UBOUND(arr, 2)
PRINT USING "Row ## "; y,
FOR x = 1 TO UBOUND(arr, 1)
PRINT USING " ##"; arr(x, y);
NEXT
PRINT
NEXT
PRINT
END SUB
There. I fixed it for downsizing one, while expanding on the other index.