Thread: Array Test
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
VBA Dabbler[_2_] VBA Dabbler[_2_] is offline
external usenet poster
 
Posts: 54
Default Array Test

I use a publicly declared dynamic array for multiple calls of the same
function, where the data does not change from call to call - this is
substantially faster than getting the data from a range, worksheet, or query
each time the function is called. However, I only need to populate the array
on the first instance of a call to the function.

I know it's an array, but won't know which call is the first,
programmatically. Typically I've been working off of the assumption that the
array exists and is populated, and handle the 'Subscript out of range' error
when it occurs.

See my responses below in square brackets.

Thanks,
VBA Dabbler

"Tom Ogilvy" wrote:

Why do you want to Check? [So that my code doesn't fail, when I know how to handle the condition.]

Seems like you should know. [See my second paragraph above.]

If it is a global variable that you are checking if it is populated then how
have you declared it?

If you used

Public v as Variant

then isarray(v) should work [It doesn't work as I need. I know it's an array - I want to know that it's populated. If it's not populated I get the 'Subscript out of range' error.]

If
Public v() as Whatever

then you have received answers for that.

--
Regards,
Tom Ogilvy


"VBA Dabbler" wrote in message
...
Does anyone know how to proactively test an array for data prior to its

use
without using an error event?

If not, what is a good error test?

I have been using 'Err.Number = 9' as a test to call the population

routine.

Thanks,
VBA Dabbler