-
Oct 21st, 2021, 07:24 AM
#1
Thread Starter
Member
Dynamic Array
Hi
How to create Dynamic array which can have multiple rows & columns
Thanks
-
Oct 21st, 2021, 09:02 AM
#2
Re: Dynamic Array
??
Code:
Dim MyArray() As Long
ReDim MyArray(0 To 10, 0 To 20)
Note: Any further Redim's are only possible on the last dimension
Code:
Dim MyArray() As Long
ReDim MyArray(0 To 10, 0 To 20)
ReDim MyArray(0 To 20, 0 To 40) 'Fails!
ReDim MyArray(0 To 10, 0 To 20, 0 To 30) 'Fails!
ReDim MyArray(0 To 10, 0 To 40) 'Works!
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 21st, 2021, 09:03 AM
#3
Re: Dynamic Array
Code:
Dim ar() As Byte
'Create 2 dimensional dynamic array
ReDim ar(0 To 10, 0 To 10)
ar(2, 2) = 40
-
Oct 21st, 2021, 09:55 AM
#4
Re: Dynamic Array
Originally Posted by Zvoni
Note: Any further Redim's are only possible on the last dimension
Code:
Dim MyArray() As Long
ReDim MyArray(0 To 10, 0 To 20)
ReDim MyArray(0 To 20, 0 To 40) 'Fails!
ReDim MyArray(0 To 10, 0 To 20, 0 To 30) 'Fails!
ReDim MyArray(0 To 10, 0 To 40) 'Works!
All of that works fine for me. It's only when you use the Preserve keyword that you're limited. A straight-up ReDim totally reinitializes the array.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Oct 21st, 2021, 10:39 AM
#5
Re: Dynamic Array
Really?
Didn‘t know that, or didn‘t remember anymore.
been a long time now…..
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|