Solved

creating a 2d array

Posted on 2002-03-30
4
157 Views
Last Modified: 2010-05-02
Hi,
Easy question.  How do you create a dynamic 2D array?  And then how do you redim this array (what is the syntax)?
0
Comment
Question by:spandex44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 6907615
'Create dynamic array
dim intNum() as Integer

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

Accepted Solution

by:
PaulHews earned 75 total points
ID: 6907620
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
 

Author Comment

by:spandex44
ID: 6907772
SO how would you go about redimming the first dimension?
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6908184
You can redim the whole thing if you don't need to preserve the contents.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question