From: Lorin on 5 Dec 2007 12:56
Instr() seems to have a limit to the size of the string it can test.
Is that defined anywhere?
In the past, I have tried to read a file into a string variable and then
search it for another string using Instr(). It fails in the multimegabyte
area - maybe a RAM problem ???
I guess I could make an array of delimited strings to search.
Anybody tested searching using Instr vs. a collection (to test if key
The string solution does provide an easy way to extract whereas the
collection is difficult to get at the key (used to test if exists).
Do not want to double memory usage by putting the value in the collection
key and item.
I will need to try a speed test on
for N=0 to Count
str = split(BigDelimitedString, Chr$(0))(N)
' do something with str here
' but how do I remove this substring now from the BigDelimitedString ???
' I will be taking the substring and putting it into a control that will
the eventually double memory usage.
' Is it better to take it off the end?
' use InstrRev to find the last delimiter, then use Left$ to get only
the front part.
' but doesn't this require double memory to manipulate?
' hmmm ... write small chunks to memory to store and compare.
' then write the small chunks to disk when done comparing and loading
and then read in small cuhnks and write to control.
to extract each item; otherwise I will have to extract to an array and I
will be back to double memory usage again.
and see if that is fast or not.
So what am I trying to do?
recurse list of folders dropped by user and load paths and filenames
encountered into listview while making sure that the listview contains a
unique set with no dups (the user could do this gain). The first drop I do
not have to check (empty starting list). And it needs to be as fast as
possible. One attempt ran over the weekend and was still only a fraction of
the way through (was using the very very slow listview.finditem()).
This is fun.
"Bob Butler" wrote:
> "Dave O." <nobody(a)nowhere.com> wrote in message
> > This may or may not be faster, but it will use less memory. Select a
> > delimiter that will never appear in the subitem then declare a string and
> > add each subitem to the string separated by the delimiter, then just use
> > Instr to see if you already have the subitem listed.
> > eg List of names, colon as delimiter
> > TestList = ":ALICE:BOB:CAROL:DAVE:ERROL:FRED:GEORGE:"
> > NewItem = "SUSAN"
> > If Instr(TestList,":" & NewItem & ":") = 0
> > If the above is true then the name is not already listed.
> > Note you may need to force everything to be the same case.
> If Instr(1,TestList,":" & NewItem & ":",vbTextCompare) =0 Then
From: DanS on 5 Dec 2007 18:34
=?Utf-8?B?TG9yaW4=?= <Lorin(a)discussions.microsoft.com> wrote in
> Is there a faster way to see if a subitem entry exists in a ListView
> than ListView.FindItem(something, lvwSubItem) ?
> Or is that something I can use in parallel with a ListView that I can
> enter an item in both controls and see if it exists in this other
> control as a test? Also, if I specify a control as sorted, do it make
> it faster to fiund things in it (maybe a binary search is used)?
> i.e. is there a control that we can search faster?
> This is what is slowing me down.
> I am trying to add unique entries to a ListView.
I'd like to help you out here, as I have done a *LOT* of Listview
programming, both the control and strictly API based as well.
But, I have no clue on to what you are trying to accomplish....
I know you are recursing a folder tree and adding something to a Listview,
and adding sub-items to some/all of the items.
If you can explain in a little more detail, maybe I can help out if you're
not already good to go.