Hi guys,

Im kinda stuck ....

I would like to show all the results found in a listview control.

So far , what im doing is in the code below. This code searches the text from txtSearch when i press the enter key, and it does the search work better then the original listview search function.

The bad part? Well it does give only 1 result, the first encountered.

I thought of adding a for next loop but im not sure if that would be a correct thing to do .. then something came up to my mind ...

Is is possible to somehow...get all the results, clear the listview and populate it with the results or adding a new listview where the results would be posted?


Cheers!

Code:
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
Dim SearchString As String
      Dim oItem As ListItem
      Dim oSubItem As ListSubItem
    '  SearchString = InputBox("", "Search", "Enter Customer Name")
    SearchString = txtSearch.Text
      For Each oItem In ListView1.ListItems
          If InStr(1, oItem.Text, SearchString, vbTextCompare) Then
              oItem.Selected = True
              oItem.EnsureVisible
              ListView1.SetFocus
              Exit For
          Else
              For Each oSubItem In oItem.ListSubItems
                  If InStr(1, oSubItem.Text, SearchString, vbTextCompare) Then
                      oItem.Selected = True
                      oItem.EnsureVisible
                      ListView1.SetFocus
                      Exit For
                  End If
              Next
              If Not oSubItem Is Nothing Then Exit For
          End If
      Next
End If