Filtering Arrays

kirkm

Registered User.
Local time
Today, 17:55
Joined
Oct 30, 2008
Messages
1,257
I'm finding the VBA Filter command just right for extracting certain things from an array.

But I prefer arrays to be 1-based and Filter usually makes them 0-based. (But not always and I'm not sure why)

I wrote a routine that looped through, moving everything up by one, so element one would be empty.
But then I thought of another way...

Code:
tArray = Join(myArray, chr$(250))
myArray = Split(Chr$(0) & tArray, Chr$(0))
(I used chr$(0) as it's an unprintable character)
What would experts here say was the 'best' method, if either ?
 
Try this in the declarations section of the module.

Code:
Option Base 1
 
I tried that first, but it had no effect on filtered arrays.
Is that a global thing for the whole mdb, or just the module it's declared in
 
personally, I would get used to them being zero-based, rather than try to make something else.

inserting a dummy array(0) value is in general hopelessly inefficient.
 
I'm kind of committed to 1-based now. Too much relies on it.
 

Users who are viewing this thread

Back
Top Bottom