testing for a null array 
Author Message
 testing for a null array

Is there some way to test whether an array has any elements in it?

dim aArray() as double
if blah then
    redim aArray(0)
    aArray(0) = 1
endif

This isn't what my code really is, but just an example of what I'm looking
for.
I can't test to see if aArray() has any elements by using UBound(..) because
I get a subscript out of range error when aArray() is empty.  I can't use
IsNull(..) either, because that
Is there another way to figure out if aArray is null?

thanks,
Tom Warner



Fri, 11 Mar 2005 15:33:44 GMT  
 testing for a null array
Hi Tom,

Store your array in a variant once filled and then test it with a function:
----------------------------------------------------
Function IsBounded(vArray as Variant) as Boolean
    On Error Resume Next
     IsBounded = IsNumeric(UBound(vArray))
End Function
----------------------------------------------------

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/


Quote:
> Is there some way to test whether an array has any elements in it?

> dim aArray() as double
> if blah then
>     redim aArray(0)
>     aArray(0) = 1
> endif

> This isn't what my code really is, but just an example of what I'm looking
> for.
> I can't test to see if aArray() has any elements by using UBound(..) because
> I get a subscript out of range error when aArray() is empty.  I can't use
> IsNull(..) either, because that
> Is there another way to figure out if aArray is null?

> thanks,
> Tom Warner



Fri, 11 Mar 2005 15:47:26 GMT  
 testing for a null array
Ah, you're the man.  Thanks.


Hi Tom,

Store your array in a variant once filled and then test it with a function:
----------------------------------------------------
Function IsBounded(vArray as Variant) as Boolean
    On Error Resume Next
     IsBounded = IsNumeric(UBound(vArray))
End Function
----------------------------------------------------

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to
the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/



Quote:
> Is there some way to test whether an array has any elements in it?

> dim aArray() as double
> if blah then
>     redim aArray(0)
>     aArray(0) = 1
> endif

> This isn't what my code really is, but just an example of what I'm looking
> for.
> I can't test to see if aArray() has any elements by using UBound(..)
because
> I get a subscript out of range error when aArray() is empty.  I can't use
> IsNull(..) either, because that
> Is there another way to figure out if aArray is null?

> thanks,
> Tom Warner



Fri, 11 Mar 2005 16:26:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

2. TEST TEST TEST TEST

3. alt.test,comp.test,misc.test,news.test

4. Testing for Null in Control

5. Test for null value in Outline code field

6. how do you ask a rowfilter to test for null

7. How to test for a NULL return value from FindByValue in vb.net

8. testing for nulls

9. ADO - how to test for empty(null) fields in a recordset

10. Null Null Null!!!!!!!!!

11. Null, Null, Null!

12. Testing NULL in DAO

 

 
Powered by phpBB® Forum Software