Solved

creating a 2d array

Posted on 2002-03-30
4
150 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 42
Best way to parse out a json string in VB6? 10 169
How to Add / Edit Windows Menu 4 60
Error with a code discussed on this page 5 14
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

777 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