Extension can't have a space in it. If there is a space after a dot, it means the dot is part of a filename. Thus... there should be a lookup for a possible next dot.
Now that I think about it, the most failproof way would be to check for a space, if is a space, mark the location, then look the next character until it finds a dot. Then take characters to the last position a space was found.
VB Code:
'in a module Public Function RemoveParams(ByVal Filename As String) As String Dim Buffer() As Byte Dim A As Long, B As Long Buffer = Filename A = (UBound(Buffer) Or 1) - 1 Do While Buffer(A) = 46 If Buffer(A) = vbKeySpace Then B = A A = A - 2 If A < 0 Then RemoveParams = Buffer: Exit Function Loop ReDim Preserve Buffer(B - 1) RemoveParams = Buffer End Function




Reply With Quote