Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if unititiated array holds any values 1

Status
Not open for further replies.

johnaregan

Programmer
Mar 13, 2001
87
Hi
I have an array declared as
Dim ar() as String
This is set by a return from another function:
ar = ReturnArrayFunction

How so I test it the ar array has been returned any values?

Thanks
John
 
If a variable is dimmed as a dynamic array then IsArray returns True whether or not the array has been initialized. There are three ways to check if it contains any values:

1. Declare it as a Variant and have the function initialize it as an array only if values are returned. Then if an array isn't returned, IsArray will return False.

2. Pass the array as a parameter and have the function return the number of values placed in it or zero if none returned. Test the function return.

3. Use an error handler to trap error 9, "subscript out of range" and proceed accordingly.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top