Login | |
|
 |
RE: Determining Array length - 11/12/2006 1:42:45 AM
|
|
 |
|
| |
ehvbs
Posts: 2222
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi TNO, use UBound() in VBScript where you would use .length in Javascript, but remember, that UBound() returns the last index: Dim a1D : a1D = Array( 10, 20, 30, 40, 50, 60, 70, 80, 90 ) Dim a2D( 1, 2 ) a2D( 0, 0 ) = "00" a2D( 0, 1 ) = "01" a2D( 0, 2 ) = "02" a2D( 1, 0 ) = "10" a2D( 1, 1 ) = "11" a2D( 1, 2 ) = "12" WScript.Echo "LBound( a1D ) =", LBound( a1D ), "UBound( a1D ) =", UBound( a1D ) WScript.Echo "UBound( a2D ) =", UBound( a2D ) WScript.Echo "UBound( a2D, 1 ) =", UBound( a2D, 1 ) WScript.Echo "UBound( a2D, 2 ) =", UBound( a2D, 2 )
|
|
| |
|
|
|
 |
RE: Determining Array length - 11/12/2006 2:20:17 AM
|
|
 |
|
| |
TNO
Posts: 1399
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
Belated thought: I'm apparently thinking of VBScript arrays in a way non-related to this particular language: Does “size” mean number of elements, bytelength of contents, memory consumed by the object? Since Arrays in vbscript are a Function with a vice an object its no wonder I'm not getting what I expected. Array(1,2,3,4,5,6,7) Is the same thing as Function(a,b,c,d,e,f,g,h) For each of the arguments, creat and return blah End Function So I guess the issue is semantics more than anything. The Ubound suggestions is probably best
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
|
|