This one is a tricky one, and displays another weakness in VBScript's array object. While most things in VBScript are 0-based, the "collection" of elements in a multi-dimensional array is actually 1-based. The default element for lbound/ubound values (these give the lowest and highest numbers in the array, respectively) is the first element. So, when you have a multi-dimensional array, the following commands do the exact same thing:
<% Dim DemoArray(10, 20) Response.Write UBound(DemoArray) Response.Write UBound(DemoArray, 1) %> |
The ,1 indicates that you want the ubound for the FIRST element in the array. So, extending that, here is how to get the lbound/ubound for other elements in the array:
<% Dim DemoArray(10, 20, 30) Response.Write UBound(DemoArray, 2) Response.Write UBound(DemoArray, 3) %> |