473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 4725
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.