I need to store information in a 2 dimensional array. I understand ArrayList
only works for a single dimensional array, is that correct ?
So, I use the 2 dimensional array like in VB6. I pass the array into a
subroutine, and inside it I "Redim Preserve" the array to increase the
number of item in the array. I got the error "Redim statement requires an
array", but arr is an array. HOw can I fix this problem ? Or, how can I do
ArrayList for 2 dimensional array ?
THank you very much.
Private arr(COM_MAX, 0) As String
LoadArr(arr)
Sub LoadArr(ByRef arr As Array)
lNumComm = 0
For x = 1 to 1000
ReDim Preserve arr(COM_MAX, lNumComm)--->Redim statement requires an array
:
next 6 2255
"fniles" <fn****@pfmail.comwrote in message
news:Ol*************@TK2MSFTNGP02.phx.gbl...
>I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ?
So, I use the 2 dimensional array like in VB6. I pass the array into a
subroutine, and inside it I "Redim Preserve" the array to increase the
number of item in the array. I got the error "Redim statement requires an
array", but arr is an array. HOw can I fix this problem ? Or, how can I do
ArrayList for 2 dimensional array ?
THank you very much.
Private arr(COM_MAX, 0) As String
LoadArr(arr)
Sub LoadArr(ByRef arr As Array)
Pass it in the same way you define the array, eg
Sub LoadArr(ByRef arr As int(,))
BTW, redim preserve does a complete copy of every element in the array every
time it's called. In your loop that will mean half a million copies for each
column.
Michael
Michael C is right about the Redim Preserve. I wouldn't do that.
I'd use an arraylist or a generic list (depending on what version
of .Net you're using.)
Robin S.
---------------------------------
"Michael C" <no****@nospam.comwrote in message
news:un**************@TK2MSFTNGP04.phx.gbl...
"fniles" <fn****@pfmail.comwrote in message
news:Ol*************@TK2MSFTNGP02.phx.gbl...
>>I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ? So, I use the 2 dimensional array like in VB6. I pass the array into a subroutine, and inside it I "Redim Preserve" the array to increase the number of item in the array. I got the error "Redim statement requires an array", but arr is an array. HOw can I fix this problem ? Or, how can I do ArrayList for 2 dimensional array ? THank you very much.
Private arr(COM_MAX, 0) As String LoadArr(arr)
Sub LoadArr(ByRef arr As Array)
Pass it in the same way you define the array, eg
>Sub LoadArr(ByRef arr As int(,))
BTW, redim preserve does a complete copy of every element in the array
every time it's called. In your loop that will mean half a million copies
for each column.
Michael
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Lp******************************@comcast.com. ..
Michael C is right about the Redim Preserve. I wouldn't do that.
I'd use an arraylist or a generic list (depending on what version
of .Net you're using.)
Or redim at the start or redim at set intervals.
Michael
why not have an Arraylist (or preferably a generic List(of T)) of Arraylists?
guy
"fniles" wrote:
I need to store information in a 2 dimensional array. I understand ArrayList
only works for a single dimensional array, is that correct ?
So, I use the 2 dimensional array like in VB6. I pass the array into a
subroutine, and inside it I "Redim Preserve" the array to increase the
number of item in the array. I got the error "Redim statement requires an
array", but arr is an array. HOw can I fix this problem ? Or, how can I do
ArrayList for 2 dimensional array ?
THank you very much.
Private arr(COM_MAX, 0) As String
LoadArr(arr)
Sub LoadArr(ByRef arr As Array)
lNumComm = 0
For x = 1 to 1000
ReDim Preserve arr(COM_MAX, lNumComm)--->Redim statement requires an array
:
next
Thank you everybody.
I would like to use ArrayList, but it does not work with 2 dimensional
array, does it ?
How can I have a 2 dimensional array ArrayList ?
"guy" <gu*@discussions.microsoft.comwrote in message
news:78**********************************@microsof t.com...
why not have an Arraylist (or preferably a generic List(of T)) of
Arraylists?
guy
"fniles" wrote:
>I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ? So, I use the 2 dimensional array like in VB6. I pass the array into a subroutine, and inside it I "Redim Preserve" the array to increase the number of item in the array. I got the error "Redim statement requires an array", but arr is an array. HOw can I fix this problem ? Or, how can I do ArrayList for 2 dimensional array ? THank you very much.
Private arr(COM_MAX, 0) As String LoadArr(arr)
Sub LoadArr(ByRef arr As Array) lNumComm = 0 For x = 1 to 1000 ReDim Preserve arr(COM_MAX, lNumComm)--->Redim statement requires an array : next
"fniles" <fn****@pfmail.comwrote in message
news:uD**************@TK2MSFTNGP06.phx.gbl...
Thank you everybody.
I would like to use ArrayList, but it does not work with 2 dimensional
array, does it ?
How can I have a 2 dimensional array ArrayList ?
You can put an array into each element of the arraylist I guess. Although
there is nothing wrong with using Redim Preserve if you limit it's use by
increasing the size of the array, say, every 1000 elements.
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: smurf |
last post by:
Seems a simple question, but I can't find a simple answer:
I have created a two dimensional array. I wish to send the data, a row at a time to a graph plotting routine which is expected a one...
|
by: Todd |
last post by:
I'm new to c++ and was wondering how to sort a 2 dimensional array. I'm
using a select sort for 1 dimensional arrays but it is not working for a 2
dimensional array. The 2 dimensional array are...
|
by: ip4ram |
last post by:
I used to work with C and have a set of libraries which allocate
multi-dimensional arrays(2 and 3) with single malloc call.
data_type **myarray
=...
|
by: Ruben |
last post by:
I'm trying to pass an array of string to a function without knowing how
many strings I have beforehand.
I've defined one functions as
char * insert(char table,int cols, char values);
out of...
|
by: Balaskas Evaggelos |
last post by:
Hi,
does anyone know how i can sort a multi-dimensional array
by a specific field ?
for example i want to sort arr where n=2,
but i need the data of every array to follow that order.
...
|
by: per9000 |
last post by:
Hi all,
I have a two-dimensional array of data, f.x int's. We can imagine that
the array is "really large". Now I want the data in it and store this
in a one-dimensional array.
The obvious...
|
by: Peter Olcott |
last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a
I think that the operator() member function does not work correctly, does
anyone else know how to make a template for making two...
|
by: nelly0 |
last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
|
by: vippstar |
last post by:
The subject might be misleading.
Regardless, is this code valid:
#include <stdio.h>
void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); }
int main(void) {
double array = { {...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |