Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

creating a 2d array

Hi,
Easy question.  How do you create a dynamic 2D array?  And then how do you redim this array (what is the syntax)?
0
spandex44
Asked:
spandex44
  • 3
1 Solution
 
PaulHewsCommented:
'Create dynamic array
dim intNum() as Integer

'Now use redim to make 2 dimensional
Redim intNum(1 to 3, 1 to 10)
0
 
PaulHewsCommented:
If you wish to resize the array and preserve the contents, use Redim Preserve.  For arrays with more than one dimension, you can only resize the final dimension, so do your planning carefully.

'Create dynamic array
dim intNum() as Integer

'Now use redim to make 2 dimensional
Redim intNum(1 to 3, 1 to 10)

intNum(1,1) = 5

'Resize final dimension...
Redim Preserve intNum(1 to 3, 1 to 20)
0
 
spandex44Author Commented:
SO how would you go about redimming the first dimension?
0
 
PaulHewsCommented:
You can redim the whole thing if you don't need to preserve the contents.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now