4 Replies - 2472 Views - Last Post: 10 January 2008 - 03:18 PM Rate Topic: -----

#1 scalt  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 342
  • Joined: 22-November 07

Resize Array From 2D to 1D

Posted 10 January 2008 - 02:06 PM

Hi

I want to know if it is possible to reduce the number of dimensions in an Array. ReDim (which, by its name, you would assume could do this) doesn't work, and it is impossible to copy from a 2-d array to a 1-d array using Array.Constrainedcopy so I can't do it that way either. It would be really great if I could avoid the whole

For i = 0 to tempArray.Length
dataArray(i) = tempArray(i)
Next



kind of solution if possible.

Any help would be appreciated.

This post has been edited by scalt: 10 January 2008 - 02:34 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Resize Array From 2D to 1D

#2 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4423
  • View blog
  • Posts: 12,292
  • Joined: 18-April 07

Re: Resize Array From 2D to 1D

Posted 10 January 2008 - 02:45 PM

Are you looking to throw away the second dimension data in the process or are you wanting all the content in the 2d to be in the 1d? So that a 2 x 2 will result in a 1 x 4? or just a 1x2 where the two elements are the first element of each row? Hope that is not confusing you. :)
Was This Post Helpful? 0
  • +
  • -

#3 scalt  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 342
  • Joined: 22-November 07

Re: Resize Array From 2D to 1D

Posted 10 January 2008 - 03:00 PM

Nope not confusing :D
I dont care about the second column of data, just want the first.

The array I'm dealing with is populated by using
dataArray = xlRng.Value


and Excel seems to like creating 2-D arrays for single columns of data.

This post has been edited by scalt: 10 January 2008 - 03:02 PM

Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4423
  • View blog
  • Posts: 12,292
  • Joined: 18-April 07

Re: Resize Array From 2D to 1D

Posted 10 January 2008 - 03:12 PM

Oh so this is VBA and not .NET?
Was This Post Helpful? 0
  • +
  • -

#5 scalt  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 342
  • Joined: 22-November 07

Re: Resize Array From 2D to 1D

Posted 10 January 2008 - 03:18 PM

No, VB.NET using an Excel module.

Due to the nature of the file I'm reading and the requirements of the users, an OLEDB connection wasn't really working.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1