Solved

creating a 2d array

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

739 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