449,370 Members | 1,552 Online
Need help? Post your question and get tips & solutions from a community of 449,370 IT Pros & Developers. It's quick & easy.

# compare path strings

 P: n/a Hi group, I want to compare path strings in order to sort them, assuming I have got: "a.txt" "dir1\c.txt" "e.txt" "dir1\d.txt" When I compare them using "e.text" would be greater than "dir1\c.txt" But I would like them to be sorted as followed "a.txt" "e.txt" "dir1\c.txt" "dir1\d.txt" so I wrote the following function to compare the strings, but I was wondering if I'm maybe missing some built in dot net function because for the moment my function is lacking support for strings containing more than one \ Private Function MyCompare(ByVal str1 As String, ByVal str2 As String) As Boolean str1 = LCase(str1) str2 = LCase(str2) If str1.IndexOf("\"c) <-1 And str2.IndexOf("\"c) = -1 Then Return True Else If str1.IndexOf("\"c) <-1 And str2.IndexOf("\"c) <-1 Then If Mid(str1, 1, str1.IndexOf("\"c)) = Mid(str2, 1, str2.IndexOf("\"c)) Then Return Mid(str1, str1.IndexOf("\"c) + 2, str1.Length - str1.IndexOf("\"c) + 2) Mid(str2, str2.IndexOf("\"c) _ + 2, str2.Length - str2.IndexOf("\"c) + 2) Else Return Mid(str1, 1, str1.IndexOf("\"c)) Mid(str2, 1, str2.IndexOf("\"c)) End If Else If str1.IndexOf("\"c) = -1 And str2.IndexOf("\"c) <-1 Then Return False Else If str1.IndexOf("\"c) = -1 And str2.IndexOf("\"c) = -1 Then Return str1 str2 End If End If End If End If End Function Greetz, Peter -- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) Jun 22 '07 #1