Results 1 to 2 of 2

Thread: Advanced String Compare, Searching

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Advanced String Compare, Searching

    Hi guys, I need your help, let say i want to search a file call: "Hello World.txt" in my PC. However, let say that "Hello World.txt" doesn't exit on my pc but a file "World Hello.txt" exist. So i want to make a function to find both file, the first thing i'm thinking of is to check for the lenght of the string but how to check word to word ??

    Hello World.txt = World Hello.txt

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Advanced String Compare, Searching

    This is similar to a "search for all terms" type thing. Where it doesn't matter if they are in order but only that they are all present.

    You can split the search term into separate words using the Split() function:

    vb Code:
    1. Dim Search As String, Words() As String
    2.  
    3. Search = "Hello world"
    4. Words() = Split(Search, " ")

    Now you have an array containing all words:

    vb Code:
    1. Words(0) = "Hello"
    2. Words(1) = "world"

    When searching for the file, you can split the file name into words as well. Then compare the 2 arrays (Words() and the array from the file name)).

    Depending on how strict you want the search to be, it could return file names that have at least one term, or only ones that have all.

    If you can post your current code for searching/listing files it will be easier to tell you how to put this code in there.

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