Results 1 to 2 of 2

Thread: Populate ListView based on search criteria?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I have the following:

    1) Text file named Text.txt with the following data:

    Blue Car
    Red Car
    Blue Truck
    Red Truck

    2) A form with a ListView (ListView1), Text box (Text1) and Command button (Command1).

    Here's what I would like to accomplish. The ListView would not be populated until the user types in some text in the text box and hits the command button. The listview would then be populated with anything that matches the text entered into the text box. So using the above data, if the user entered bl in the search box, the listview would be populated with:

    Blue Car
    Blue Truck

    Any ideas on how to accomplish this would be appreciated..

    Dan

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I assume you know how to read the text file. So once you have done that you can put each line in MyString and do something like the following:
    Code:
        Dim strLookFor As String
        Dim MyString As String
        
        MyString = "Blue Truck"
        strLookFor = "bl"
        
        If InStr(1, UCase(MyString), UCase(strLookFor)) Then
            MsgBox "I found it"
        End If
    By the way, the above is not case sensitive. To make it case sensitive just remove the UCase functions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width