Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Question About arrays

Reply
 
Old 09-16-2008   #1 (permalink)
Bob Smith


 
 

Question About arrays

I have a 2 Dimentional Array that is of size ArrayAD(1500,9). Basically I
would like to loop through everything in the X axis and pull the results for
that line into a string. Once I have this I would like to move to the next
record.

This is what I have come up with so far, it's super ugy. Is there a better
way to do this?

ax = UBound(ArrayAD,1)
ay = UBound(ArrayAD,2)

For x = 0 To ax
tmpString = ""
For y = 0 To ay
ttmpString=tmpString & ArrayAD(x,y) & "|"
Next
wscript.echo tmpString
Next

My System SpecsSystem Spec
Old 09-16-2008   #2 (permalink)
James Whitlow


 
 

Re: Question About arrays

"Bob Smith" <BobSmith@xxxxxx> wrote in message
news:F1BF1A8C-3037-421B-A2E0-61409B4376B1@xxxxxx
Quote:

>I have a 2 Dimentional Array that is of size ArrayAD(1500,9). Basically I
> would like to loop through everything in the X axis and pull the results
> for
> that line into a string. Once I have this I would like to move to the next
> record.
>
> This is what I have come up with so far, it's super ugy. Is there a better
> way to do this?
>
> ax = UBound(ArrayAD,1)
> ay = UBound(ArrayAD,2)
>
> For x = 0 To ax
> tmpString = ""
> For y = 0 To ay
> ttmpString=tmpString & ArrayAD(x,y) & "|"
> Next
> wscript.echo tmpString
> Next
How about:

For Each sElement in ArrayAD
MsgBox sElement
Next


My System SpecsSystem Spec
Old 09-16-2008   #3 (permalink)
Al Dunbar


 
 

Re: Question About arrays


"James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message
news:OylVRTFGJHA.2076@xxxxxx
Quote:

> "Bob Smith" <BobSmith@xxxxxx> wrote in message
> news:F1BF1A8C-3037-421B-A2E0-61409B4376B1@xxxxxx
Quote:

>>I have a 2 Dimentional Array that is of size ArrayAD(1500,9). Basically I
>> would like to loop through everything in the X axis and pull the results
>> for
>> that line into a string. Once I have this I would like to move to the
>> next
>> record.
>>
>> This is what I have come up with so far, it's super ugy. Is there a
>> better
>> way to do this?
>>
>> ax = UBound(ArrayAD,1)
>> ay = UBound(ArrayAD,2)
>>
>> For x = 0 To ax
>> tmpString = ""
>> For y = 0 To ay
>> ttmpString=tmpString & ArrayAD(x,y) & "|"
>> Next
>> wscript.echo tmpString
>> Next
>
> How about:
>
> For Each sElement in ArrayAD
> MsgBox sElement
> Next
That would display each element in the array in a separate msgbox (or
wscript.echo record), whereas, I think he wants to display each "row" of the
array as a unit.

Ideally, his inner loop should be replaced by a call to the "JOIN" function.
Unfortunately, that function accepts a parameter of type array, whereas
there is no syntactical way to refer to a row (or column) of a two
dimensional array as if it were itself an array.

The above may seem super ugly, but it will work. It might be possible to
beautify that part of the code by restructuring the two dimensional
rectangular array into a one-dimensional array whose elements are,
themselves, one-dimensional arrays equivalent to the rows of the 2D array.

While that might make this particular code less ugly, ir might require
significant "uglification" elsewhere to accommodate the new data structure.

/Al


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Comparing arrays PowerShell
Arrays PowerShell
Overwriting Arrays PowerShell
Working with arrays PowerShell
question about arrays PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46