473,461 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

adding a dimension to an array

I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and
manually put a value in there based on the contents of the first element. I
can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.

Can I do this? How? TIA!

Matt
Nov 20 '05 #1
4 4729
Matt,

I don't believe you can add a dimension to an array. I would declare a new
array and use array.copy to move the contents of the old 1-dim array into
the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yahoo.com> wrote in message
news:c5***********@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and manually put a value in there based on the contents of the first element. I can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.

Can I do this? How? TIA!

Matt

Nov 20 '05 #2
* "MattB" <so********@yahoo.com> scripsit:
I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and
manually put a value in there based on the contents of the first element. I
can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.


You cannot change the number of dimensions in an array, you will have to
create a new array with more dimensions and copy over data.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
I was actually just trying that approach. I'm having trouble using
array.copy to go from a one-demensional array to a two-dimensional array.
Anyone got a sample? Thanks!

Matt

Raymond Lewallen wrote:
Matt,

I don't believe you can add a dimension to an array. I would declare
a new array and use array.copy to move the contents of the old 1-dim
array into the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yahoo.com> wrote in message
news:c5***********@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list
using string.split. Now I'd like to take that array and add another
dimension and manually put a value in there based on the contents of
the first element. I can loop through my array no problem, but I
don't see how (if?) I can add another "column" to it. Seems like it
should be simple.

Can I do this? How? TIA!

Matt


Nov 20 '05 #4
Mattb,
Array.Copy requires both arrays to have the same dimensions.

You will have to use a For loop to copy the elements.

Something like:

Dim x(9) As Integer
Dim y(9, 1) As Integer
For index As Integer = 0 To x.Length - 1
y(index, 0) = x(index)
Next

Hope this helps
Jay

"MattB" <so********@yahoo.com> wrote in message
news:c5***********@ID-86156.news.uni-berlin.de...
I was actually just trying that approach. I'm having trouble using
array.copy to go from a one-demensional array to a two-dimensional array.
Anyone got a sample? Thanks!

Matt

Raymond Lewallen wrote:
Matt,

I don't believe you can add a dimension to an array. I would declare
a new array and use array.copy to move the contents of the old 1-dim
array into the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yahoo.com> wrote in message
news:c5***********@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list
using string.split. Now I'd like to take that array and add another
dimension and manually put a value in there based on the contents of
the first element. I can loop through my array no problem, but I
don't see how (if?) I can add another "column" to it. Seems like it
should be simple.

Can I do this? How? TIA!

Matt


Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Kirchner | last post by:
Hi everybody The output of my multiple dimension array is quite confusing. Im declaring an array, store some values in it and then I save the array in a session variable. On an other page I...
9
by: James | last post by:
Hi, I am new to C++. I want to directly create a dynamic two-dimension double array, i.e. double pp. I found the "new" is only for one-dimension array, i.e. double *p = new p. How to "new" a...
6
by: Adam Hartshorne | last post by:
The input to a function of a 3rd party library I want to use requires a double**, which is a multi-dimension array of doubles. I have looked on the net etc and seen several ways of supposedly...
2
by: YFS DBA | last post by:
Hello again; I've got a small invoicing database I'm trying to create. One of the tables is set up as follows: Client# Date Claim# Amount 1001 10/10/03 ...
4
by: Bill Sun | last post by:
Hi, All I have a conventional question, How to create a 3 dimension array by C language. I see some declare like this: int *** array; int value; array = create3Darray(m,n,l);
4
by: MattB | last post by:
I have an one dimensional array being created from a delimited list using string.split. Now I'd like to take that array and add another dimension and manually put a value in there based on the...
2
by: Nathan Sokalski | last post by:
I have a multidimensional array declared as the following: Dim guesses(14, 5) As Integer I want to assign all values in a specific dimension to another array declared as follows:
5
by: Jackson | last post by:
I have something that is stumping me. I am trying to initialize a 3 dimensional string array with the code below, but it wont compile. Can anyone explain what Im doing wrong?????????????? Im...
9
by: dennis.sam | last post by:
Hi, Is there away to define a multi-dimensional array with respect to the number of dimensions the array has? For example, given a user spec of "a b c d", I want to create a 4 dimensional array...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.