Test if an array is filled

J

Jeff Hunt

Is there any way to tell if an array has been filled? I'm using Access 2003.
I have a string array that only gets filled under certain conditions (using
split() on another variable). I haven't figured out a way to see if there
are values in the array, functions like IsEmpty and IsNull always return
False whether it is filled or not.

I realize I can just keep my own Boolean variable that becomes true only if
the condition triggers the array to be filled, but if there is already a
function to test it, I'd like to know (especially for future use where I may
have multiple arrays to test and don't want to track just as many Booleans).

While I'm posting, is there any function that automatically empties an array
(remove all elements, so the UBound is 0 or null)?
 
S

Stuart McCall

Jeff Hunt said:
Is there any way to tell if an array has been filled? I'm using Access
2003.
I have a string array that only gets filled under certain conditions
(using
split() on another variable). I haven't figured out a way to see if there
are values in the array, functions like IsEmpty and IsNull always return
False whether it is filled or not.

I realize I can just keep my own Boolean variable that becomes true only
if
the condition triggers the array to be filled, but if there is already a
function to test it, I'd like to know (especially for future use where I
may
have multiple arrays to test and don't want to track just as many
Booleans).

While I'm posting, is there any function that automatically empties an
array
(remove all elements, so the UBound is 0 or null)?

Well you can test the Ubound, and if you get an error, the array hasn't been
filled. As far as emptying the array, use:

Erase ArrayName

This clears the elements and releases the memory they occupied.
 
C

Clifford Bass

Hi Jeff,

Note that the Split() function can return an array with an upper bound
of -1 if there was nothing to split.

Dim strarrData() As String

strarrData = Split("", ",")
MsgBox(UBound(strarrData))

Clifford Bass
 

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