I am trying to determine if a string contains .txt in it(like a text file: list.txt, readme.txt, etc...).
If it does I need to remove the .txt from the string but leave the file name(list, readme, etc...).
Is there a wildcard to use or what?
For this example, assume FileName is a string containing the name "readme.txt"
Dim ExtensionPos As Long
Dim FileName As String
FileName = "readme.txt"
'InStr will return the position of .txt in the string
ExtensionPos = InStr(FileName, ".txt"
If ExtensionPos > 0 Then
'Assign the part of the string before .txt to FileName
FileName = Mid(FileName, 1, ExtensionPos - 1)
End If
Ruairi
Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
'find out if it is a .txt
if right$(sYourFile,3) = "txt" then
'copy it to a new(or same) directory without the .txt
apiCopyFile sYourFile, left$(sYourFile,len(sYourfile-4), False
'delete original
KILL sYourfile
end if
Sorry it is so messy, I am on my way to lunch, I will check back
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.