[AccessD] Test whether Array initialised

Jim Lawrence accessd at shaw.ca
Sat Jun 20 14:21:46 CDT 2009


You are brilliant Stuart. 

Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Saturday, June 20, 2009 5:43 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Test whether Array initialised

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 
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list