468,103 Members | 1,333 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

Accessing one dimension of a multidimensional array

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:
Dim currguess(5) As Integer
I would have thought this would be done using something like the following
where x is the dimension I want to copy:
currguess=guesses(x)
However, VB.NET does not seem to like this. What can I do to copy only a
specific dimension to another array? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Apr 30 '06 #1
2 4313
youd need to put it in a for loop and do it manually

Dim guesses(14, 5) as integer
Dim currGuess(5) as integer

for x as Integer = 0 to 5

currGuesses(x) = guesses(3,X)

Next

--
-iwdu15
Apr 30 '06 #2
hello,

do you realize, if you're copying the last dimension, that is
practically all the values in the entire array (think of it as a
relational database where the second dimension is sub/child table
related to the parent table which would be the first dimension), if
you're refering to an array of arrays, that is different ie:

dim arrayOfArrays()() as integer

Here the where the last dimension is all integers, and the first
dimension is of type "Array" ie: ( "TypeOf arrayOfArrays(0) Is Array"
would be true and "TypeOf arrayOfArrays(0)(0) Is Integer" would also be
true, of course given arrayOfArrays are initialized).

of course, if you are just trying to copy the first dimension, or any
dimension except the last one, then that would make sense. looping it
would do, however, for efficiency purposes you should always try to use
microsofts implementations which apply to objects of type Array.

I believe they have various methods, but to make use of these you would
need to create an array of arrays, and just access the objects
following your array like this...

arrayOfArrays(3). [and this is where the intellisense will help you
with more information, since this is an Array object, you'll get all
the mass data manipulation methods available]

hope that helps, let me know if you would like further clarification.

cheers.

Apr 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by John Pastrovick | last post: by
3 posts views Thread by Eric Laberge | last post: by
9 posts views Thread by Steve Wasser | last post: by
3 posts views Thread by Jan Hanssen | last post: by
38 posts views Thread by djhulme | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.