View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default EXCLUDING DUPES IN STRING ARRAY !!!!

Considering all else (the array will be used somewhere, so the check for
duplicates is not the only deciding factor)
I doubt there are better ways than just looping through the array, but a few
things to consider:
1. Is the string array sorted? If it is then you could check with a binary
search. That will be a lot faster than a full loop.
2. Could you use a collection or dictionary instead of the array? With that
the check for duplicates might be faster.
3. You could have the array in a string variable, eg: element1 & | element2
& | etc. With that you could than check with
Instr. Concatenating the strings though will be a big overhead, so I doubt
it will help.
4. You could use Olaf Schmidt's dhRichClient3.dll. That has a very fast
collection object and dictionary object.
5. You could invest in Jim Mach's Stamina dll. That has some fast array
routines that could speed this up.
Can't think of much else.

RBS



"jay dean" wrote in message
...
Hi -

B is a string var. In my code, if a certain condition is met, then store
B in th next available index of Arr(). However, before I store B, I need
to check that the current value of B does not already exist in Arr().

Is there a "faster" way to accomplish this, or I need to loop from
lbound(Arr) to Ubound(Arr) every time to check if the new value to be
stored already exists?

Thanks
Jay Dean



*** Sent via Developersdex http://www.developersdex.com ***