-
Hi
I am trying to write a function that works with files that only have a ".txt" extension.
code:
str1 = '(Whatever the filename is)
str2 = "*.txt"
intCompare1 = str1 Like str2
if intCompare1 = "-1" then
msgbox("Contains txt file")
else
msgbox("Does not contain txt file")
end if
Question: How do I include in the comparrison, variations of .txt? (eg. *.txt, *.TXT, *.Txt etc...)
Thanks
Gregg
-
Why not just convert it to lowercase? Whether it's uppercase or lowercase, it's still the same file.
Code:
str1 = LCase$("C:\FILE.TXT")
str2 = ".txt"
If Instr(str1, str2) Then
Msgbox ("Contains txt file")
Else
Msgbox ("Does not contain txt file")
End If
-
Convert both to lower case and the test will always be true
Code:
intCompare1 = lcase(str1) like lcase(str2)
-
Thanks for your help guys.
Much appreciated...
Gregg
-
Gen-X, two great minds think alike :).
-
YOu could just put option compare text, in the declarations instead of using lcase$