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

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License