Array dimension

'

' returns the number of dimensions for a given array

'

'

' IN: arr - the array to test (can be n-dimensional)

' OUT: array_dimensions - Integer number of dimensions (0 if not an array)

'

Function array_dimensions(ByVal arr)

Dim i

i = 0

If isarray(arr) Then

' there is no dimension check in VBScript, so we have to do it via trial & error

On Error Resume Next

i = 0

Do

i = i + 1

lbound arr, i

Loop While err.number = 0

Err.clear

i = i - 1

On Error GoTo 0

End If

array_dimensions = i

End Function

page revision: 3, last edited: 03 Sep 2008 10:47