by MudBlud (8 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)
splits a path up a path and shortens parts to make it shorter.
e.g.
c:\program files\blingblongblu\bah\bleh.exe
c:\program...\blingbl...\bah\bleh.exe
Inputs
path
Code Returns
shorten'd path
Private Function ShortenPath(Path As String, MaxLen As Integer) As String
Dim bleh() As String
bleh = Split(Path, "\")
For x = 0 To UBound(bleh)
If Not x = UBound(bleh) Then
If Len(bleh(x)) > MaxLen Then
bleh(x) = Mid$(bleh(x), 1, MaxLen - 3) & "..."
End If
tmp = tmp & bleh(x) & "\"
Else
tmp = tmp & bleh(x)
End If
Next
ShortenPath = tmp
End Function