Truncate long path names
Posted by: fredometro on
May 25th, 2007 |
Filed under: MS-Access
This function is useful when displaying or logging long path names.
Too long path names are annoying in a log file, because they are very often the same. Truncating the path to show only the beginning and the end helps readability.
Public Function TruncatedPath(TheText)
Dim pos1 As Integer
Dim pos2 As Integer
Dim ch As String
Dim i As Integer
pos1 = InStr(3, TheText, "\")
i = Len(TheText)
ch = Mid(TheText, i, 1)
While ch <> "\"
i = i - 1
ch = Mid(TheText, i, 1)
Wend
pos2 = Len(TheText) - i + 1
TruncatedPath = Left(TheText, pos1) & "..." & Right(TheText, pos2)
End Function
No related posts.

Tags:
Add A Comment
You must be logged in to post a comment.