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
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:
Dim Search As String, Words() As String
Search = "Hello world"
Words() = Split(Search, " ")
Now you have an array containing all words:
vb Code:
Words(0) = "Hello"
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.