[AccessD] Test whether Array initialised

Stuart McLachlan stuart at lexacorp.com.pg
Sat Jun 20 07:43:02 CDT 2009


I've been doing quite a bit with arrays in the last couple of days using 
....
ReDim Preserve myArray(UBound(MyArray()) +1)
....

This works fine it the array has been  initialized, but throws an error the first time round 
because the array has not been initialized.  I've just come across a neat hack to test whether 
the array has been initialized:

"IF NOT NOT myArray()" ...  

This takes the 32-bit pointer value in the array variable, mirror the bits, and then mirror them 
again.  If the array has not been initialized, the pointer is 0 so it returns false, if it has been, 
it returns the pointer value. Since this is non-zero, it returns true. 

-- 
Stuart 



More information about the AccessD mailing list