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 - Array help please

Reply
 
Old 12-30-2008   #1 (permalink)
Bob Smith


 
 

Array help please

I need to know how I can query the size of the second element in 2 two
dimentional array. In the example below it would be 3. I tried UBound and
LBound but they don't give me the result.

Dim myarray

ReDim myarray(1,3)

myarray(0,0)="A"
myarray(0,1)="AA"
myarray(0,2)="AAA"
myarray(0,3)="AAAA"
myarray(1,0)="A"
myarray(1,1)="AA"
myarray(1,2)="AAA"
myarray(1,3)="AAAA"


My System SpecsSystem Spec
Old 12-30-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Array help please


"Bob Smith" <BobSmith@xxxxxx> wrote in message
news:E4424F42-C075-44EB-A2A4-322E6366B177@xxxxxx
Quote:

>I need to know how I can query the size of the second element in 2 two
> dimentional array. In the example below it would be 3. I tried UBound and
> LBound but they don't give me the result.
>
> Dim myarray
>
> ReDim myarray(1,3)
>
> myarray(0,0)="A"
> myarray(0,1)="AA"
> myarray(0,2)="AAA"
> myarray(0,3)="AAAA"
> myarray(1,0)="A"
> myarray(1,1)="AA"
> myarray(1,2)="AAA"
> myarray(1,3)="AAAA"
>
Try this:
wscript.echo UBound(myarray,2)
(found in the downloadable VB Script help file script56.chm)


My System SpecsSystem Spec
Old 12-30-2008   #3 (permalink)
ekkehard.horner


 
 

Re: Array help please

Bob Smith schrieb:
Quote:

> I need to know how I can query the size of the second element in 2 two
> dimentional array. In the example below it would be 3. I tried UBound and
> LBound but they don't give me the result.
>
> Dim myarray
>
> ReDim myarray(1,3)
>
> myarray(0,0)="A"
> myarray(0,1)="AA"
> myarray(0,2)="AAA"
> myarray(0,3)="AAAA"
> myarray(1,0)="A"
> myarray(1,1)="AA"
> myarray(1,2)="AAA"
> myarray(1,3)="AAAA"
>
I'm not sure, I understand your "the size of the second element" correctly,
but if you mean "size of the second dimension":

WScript.Echo "UBound( myarray, 1 [= first dimension] )", UBound( myarray, 1 )
WScript.Echo "UBound( myarray, 2 [= second dimension] )", UBound( myarray, 2 )

output:

UBound( myarray, 1 [= first dimension] ) 1
UBound( myarray, 2 [= second dimension] ) 3

My System SpecsSystem Spec
Old 12-30-2008   #4 (permalink)
Bob Smith


 
 

Re: Array help please

Thanks for your help!

"ekkehard.horner" wrote:
Quote:

> Bob Smith schrieb:
Quote:

> > I need to know how I can query the size of the second element in 2 two
> > dimentional array. In the example below it would be 3. I tried UBound and
> > LBound but they don't give me the result.
> >
> > Dim myarray
> >
> > ReDim myarray(1,3)
> >
> > myarray(0,0)="A"
> > myarray(0,1)="AA"
> > myarray(0,2)="AAA"
> > myarray(0,3)="AAAA"
> > myarray(1,0)="A"
> > myarray(1,1)="AA"
> > myarray(1,2)="AAA"
> > myarray(1,3)="AAAA"
> >
> I'm not sure, I understand your "the size of the second element" correctly,
> but if you mean "size of the second dimension":
>
> WScript.Echo "UBound( myarray, 1 [= first dimension] )", UBound( myarray, 1 )
> WScript.Echo "UBound( myarray, 2 [= second dimension] )", UBound( myarray, 2 )
>
> output:
>
> UBound( myarray, 1 [= first dimension] ) 1
> UBound( myarray, 2 [= second dimension] ) 3
>
>
My System SpecsSystem Spec
Old 12-30-2008   #5 (permalink)
Bob Smith


 
 

Re: Array help please

Thanks for the help!

"Pegasus (MVP)" wrote:
Quote:

>
> "Bob Smith" <BobSmith@xxxxxx> wrote in message
> news:E4424F42-C075-44EB-A2A4-322E6366B177@xxxxxx
Quote:

> >I need to know how I can query the size of the second element in 2 two
> > dimentional array. In the example below it would be 3. I tried UBound and
> > LBound but they don't give me the result.
> >
> > Dim myarray
> >
> > ReDim myarray(1,3)
> >
> > myarray(0,0)="A"
> > myarray(0,1)="AA"
> > myarray(0,2)="AAA"
> > myarray(0,3)="AAAA"
> > myarray(1,0)="A"
> > myarray(1,1)="AA"
> > myarray(1,2)="AAA"
> > myarray(1,3)="AAAA"
> >
>
> Try this:
> wscript.echo UBound(myarray,2)
> (found in the downloadable VB Script help file script56.chm)
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Fast copy method of sub array (=array range) possible? VB Script
How to create array without quotes? $array = (a,b,c) PowerShell
Array indexing: Want to say "Item #2 through the rest of the array." PowerShell
Stupid Array Tricks: Initializing an Array to a Certain Size PowerShell
how to assign values to array and how to create array via variable 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