(06-20-2024, 03:25 PM)12centuries Wrote: I'm wondering where those "missing" numbers went and why they're not accessible to the array after redimming to a larger array, and why they return after redimming to the original size. Also, why there are extra zeros in between the existing data after the initial resize.
I think I may take a look at the source code for this...
As I mentioned, you're not printing your whole array. Here's your actual first array (REDIM SHARED Grid(5, 5)):
Code: (Select All)
Array Values:
Row 0 0 0 0 0 0 0
Row 1 0 1 2 3 4 5
Row 2 0 6 7 8 9 10
Row 3 0 11 12 13 14 15
Row 4 0 16 17 18 19 20
Row 5 0 21 22 23 24 25
And here's the resized version of it (REDIM PRESERVE Grid(10, 10)):
Code: (Select All)
Array Values:
Row 0 0 21 18 15 0 0 0 0 0 0 0
Row 1 0 0 23 20 0 0 0 0 0 0 0
Row 2 0 2 0 25 0 0 0 0 0 0 0
Row 3 0 7 4 0 0 0 0 0 0 0 0
Row 4 0 12 9 0 0 0 0 0 0 0 0
Row 5 0 17 14 0 0 0 0 0 0 0 0
Row 6 0 22 19 0 0 0 0 0 0 0 0
Row 7 1 0 24 0 0 0 0 0 0 0 0
Row 8 6 3 0 0 0 0 0 0 0 0 0
Row 9 11 8 5 0 0 0 0 0 0 0 0
Row 10 16 13 10 0 0 0 0 0 0 0 0
Now, look at this resized array, and ONLY print the values from (1 to 5, 1 to 5), and see if it doesn't print the results you're seeing, completely.
Your arrays are from (0 to 5, 0 to 5), which affects them as above. You're ust printing them from (1 to 5, 1 to 5), and that makes it seem as if values are totally scrambled or even lost.
Remember: QB64PE arrays are 0-based, unless you specify otherwise.