View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Mike NG Mike NG is offline
external usenet poster
 
Posts: 87
Default Handling ubound on an uninitialised array

On Mon, 24 Jan 2005 at 04:46:27, Tushar Mehta (Tushar Mehta
) wrote:
Of course, it doesn't distinguish between an uninitialized array and a
non-array, returning zero in both cases. To distinguish between the
two:
Function ArrDim(vArr As Variant) As Integer
Dim i As Long, x As Long
If Not IsArray(vArr) Then ArrDim = -1: Exit Function '<<<<<
On Error GoTo XIT
i = 1
Do
x = LBound(vArr, i)
i = i + 1
Loop While True
XIT:
ArrDim = i - 1
End Function

I understand the theory behind the parameter being variant, but I can't
get this to compile. Keep getting
"Only user-defined types defined in public object models can be coerced
to or from a variant or passed to late bound functions"

I had all of my original code in Module1, and added your function, then
tried to call it thus
Msgbox ArrDim(Filtered)

I've tried all combinations of the variable and the function being
normal and declared public, but I can't get the compile error to clear
--
Mike
Please post replies to newsgroup to benefit others
Replace dead spam with ntl world to reply by email