TESTING FOR EMPTY ARRAY

J

JingleRock

I am downloading a 2-dimensional, zero-based, Variant array from
Bloomberg for various securities. For any given security, there are
three situations: 1) the array is empty; 2) there are two elements
(one row, two columns); or 3) there are two or more elements in each
column. There will always be an equal number of elements in each
column. My code needs to be able to distinguis between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each. When testing LBound(Dimension 2) and UBound(Dimension
2) for situation 1, I get the error "Subscript out of range".

I have tried the following:
If Not IsArray(vtData(x, 0)) Then 'where x = 0 To UBound(Dimension
1)
Result ==> both situation 1 and 2, value is False

and
If IsEmpty(vtData(0, 0)(x, 0) 'where x = 0 To UBound(Dimension 1)
Result ==> for situation 1, I get the error "Subscript out of range".

Help.
 
J

Joel

I think you already have the answer. If UBound = 0, then your have
situation 1. Don't do any more testing.
 
T

Tom Ogilvy

Dim ub2 as Long
Dim bSit1 as Boolean
if Ubound(v,1) = 0 then

on Error Resume Next
ub2 = Ubound(v,2)
if err <> 0 then _
bSit1 = True

on Error goto 0

if bSit1 then
 
J

JingleRock

I think you already have the answer. If UBound = 0, then your have
situation 1. Don't do any more testing.


Maybe this was not clear:
My code needs to be able to distinguish between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top