I want to compare two strings letter by letter. Why it is to find the filename to get the path. How do I do this??
Printable View
I want to compare two strings letter by letter. Why it is to find the filename to get the path. How do I do this??
Code:Option Explict
Option Compare Text
'event code
'StrComp function returns a number...0 if matched, 1 if false
'compare strings to see if you have a matching string or not
'
strMyCompare = StrComp(string1, String2, 1) 'comparison function
If StrMyComp = 0 then
'do bla bla bla because one = two
'do bla bla bla
'or... if false then
Else
'do bla bla bla because one <> Two
End If
Will this return true if only part of the string matches? My problem is that I'm comparing a filename string to a path + filename string. I need to get the full path for the filename. I have a collection that stores the path + filename. I have a list box that contains the filename. I'm using the filename from the list box to compare to the path + filename in the collection. Is there away to just compare
the last part of a string??
Example: C:\AB Directory\TestDir\Mergedfiles.pdf
result = compare "Mergedfiles.pdf" to _
"C:\AB Directory\TestDir\Mergedfiles.pdf"
the result should be yes
Code:If strFileName = Right$(strPath, Len(strFileName)) Then
'Bingo!
End If
Thanks!!!