M
Morten Snedker
Scenario:
From a given folder all files from all subdirs are read. These are
dropped in a one-dimensional array - myArray.
Once everything is in my array it is sorted and dropped in a listbox.
In a textbox I can enter a search criteria. Each time I press a key
the listbox is cleared and I run this code (at this point the listbox
is cleared), which fills to another array - subArray:
iLB = myArray.GetLowerBound(0)
iUB = myArray.GetUpperBound(0)
For i = iLB To iUB
If Not str = Nothing Then
If InStr(1, str, Me.txtSearch.Text,
CompareMethod.Text) > 0 Then
ReDim Preserve subArray(intSubArray)
subArray(intSubArray) = str
intSubArray += 1
End If
End If
Next
So, I see if the string in the textbox is in the string of each index
in my array. This runs fine when having less than 1000 files/indexes.
But in some cases I have more than 6000 thousand indexes, which makes
running through the array too slow.
I could demand a minium of characters to be entered before performing
my search, but I rather want to know if I could do something
differently to speed up the process?
Is InStr the wrong method? Is the array an improper method? In time my
app will be running against an SQL-Server - perhaps saving to a
tmp-table instead of an array would be better?
Thanks for any input as well as time spend on this! =B-)
Regards /Snedker
From a given folder all files from all subdirs are read. These are
dropped in a one-dimensional array - myArray.
Once everything is in my array it is sorted and dropped in a listbox.
In a textbox I can enter a search criteria. Each time I press a key
the listbox is cleared and I run this code (at this point the listbox
is cleared), which fills to another array - subArray:
iLB = myArray.GetLowerBound(0)
iUB = myArray.GetUpperBound(0)
For i = iLB To iUB
If Not str = Nothing Then
If InStr(1, str, Me.txtSearch.Text,
CompareMethod.Text) > 0 Then
ReDim Preserve subArray(intSubArray)
subArray(intSubArray) = str
intSubArray += 1
End If
End If
Next
So, I see if the string in the textbox is in the string of each index
in my array. This runs fine when having less than 1000 files/indexes.
But in some cases I have more than 6000 thousand indexes, which makes
running through the array too slow.
I could demand a minium of characters to be entered before performing
my search, but I rather want to know if I could do something
differently to speed up the process?
Is InStr the wrong method? Is the array an improper method? In time my
app will be running against an SQL-Server - perhaps saving to a
tmp-table instead of an array would be better?
Thanks for any input as well as time spend on this! =B-)
Regards /Snedker