Possible Duplicate:
How do I determine if an array is initialized in VB6?
I declare an array initially as empty:
Dim ArrayVar() as Variant
'May add some data, may not
if something then
Redim Preserve ArrayVar(ubound(ArrayVar,1)+1)
ArrayVar(ubound(ArrayVar,1)) = "something"
end if
'Always check size of array
if ubound(ArrayVar,1) > x
the problem is sometimes when I reach checking the size, nothing has been added- the array is empty and I get a run-time error. I did try declaring the array with Dim ArrayVar(0) as Variant
but then the redim statement wouldnt compile.
Whats the best way to do this?