Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered
in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)
Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(tx tfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass
For i = listview1.ListI tems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1 .ListItems(i), SearchItem) > 0 Then
Else
With listview1.ListI tems
.Remove (i)
End With
End If
Next
done:
Me.MousePointer = vbDefault
End Sub
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered
in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)
Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(tx tfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass
For i = listview1.ListI tems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1 .ListItems(i), SearchItem) > 0 Then
Else
With listview1.ListI tems
.Remove (i)
End With
End If
Next
done:
Me.MousePointer = vbDefault
End Sub
Comment