Function GetArryCount(Temp() As Integer) As Integer Dim i As Integer Dim T As Integer Const ItemCount = 1000 On Error GoTo Err1 For i = 0 To ItemCount T = UBound(Temp, i + 1) Next i Err1: GetArryCount = i End Function
Public Function Dimensions(VariantArray) As Integer 'Determine the number of dimensions for a Variant array 'handle all errors locally On Error GoTo Dimensions_Err
'define local variables Dim Ctr As Integer Dim TestVal As Long
Do 'loop and increment counter Ctr = Ctr + 1 'test then upper bound of the dimension TestVal = UBound(VariantArray, Ctr) Loop
Dimensions_Cont: 'all done Exit Function
Dimensions_Err: 'When an error occurs we have exceeded the number of 'dimensions in our variant array by one. The true number 'of dimensions is the counter less one. Dimensions = Ctr - 1
'Reset then Err object and exit the function Resume Dimensions_Cont End Function
Dim i As Integer
Dim T As Integer
Const ItemCount = 1000
On Error GoTo Err1
For i = 0 To ItemCount
T = UBound(Temp, i + 1)
Next i
Err1:
GetArryCount = i
End Function
'Determine the number of dimensions for a Variant array 'handle all errors locally
On Error GoTo Dimensions_Err
'define local variables
Dim Ctr As Integer
Dim TestVal As Long
Do
'loop and increment counter
Ctr = Ctr + 1
'test then upper bound of the dimension
TestVal = UBound(VariantArray, Ctr)
Loop
Dimensions_Cont:
'all done
Exit Function
Dimensions_Err:
'When an error occurs we have exceeded the number of
'dimensions in our variant array by one. The true number
'of dimensions is the counter less one.
Dimensions = Ctr - 1
'Reset then Err object and exit the function
Resume Dimensions_Cont
End Function