Someone posted a great little function here the other day that separated the full path of a file into several parts that looked like this:
Function BreakDown(Full As String, FName As String, PName As String, Ext As String) As Integer
If Full = "" Then
BreakDown = False
Exit Function
End If
If InStr(Full, "\") Then
FName = Full
PName = ""
Sloc% = InStr(FName, "\")
Do While Sloc% <> 0
PName = PName + Left$(FName, Sloc%)
FName = Mid$(FName, Sloc% + 1)
Sloc% = InStr(FName, "\")
Loop
Else
PName = ""
FName = Full
End If
Dot% = InStr(Full, ".")
If Dot% <> 0 Then
Ext = Mid$(Full, Dot%)
Else
Ext = ""
End If
BreakDown = True
End Function
However if the line continues past that point it counts it as part of the extension, is there anyway to make this only count to 3 characters after the last period in a string?
From stackoverflow
-
If you just have blank characters then just add this as the first line
Full = Trim(Full)If you have other characters then
Change:
Ext = Mid$(Full, Dot%)to:
Ext = Mid$(Full, Dot%, 3) -
Dot% = InStrRev(Full, ".") ' First . from end of string If Dot% <> 0 Then Ext = Mid$(Full, Dot%, 3) Else Ext = "" End IfMid$ syntax: Mid(string, start[, length])
0 comments:
Post a Comment