This might not be the best way but it works :
VB Code:
Private Function ATrim(Str As String, Trim As String, MatchCase As Boolean) As String Dim Check As Boolean Check = True Do While Check = True If MatchCase = True Then If Left$(Str, Len(Trim)) = Trim Then Str = Mid$(Str, Len(Trim) + 1) Else Check = False End If Else If LCase(Left$(Str, Len(Trim))) = LCase(Trim) Then Str = Mid$(Str, Len(Trim) + 1) Else Check = False End If End If Loop Check = True Do While Check = True If MatchCase = True Then If Right$(Str, Len(Trim)) = Trim Then Str = Mid$(Str, 1, Len(Str) - Len(Trim)) Else Check = False End If Else If LCase(Right$(Str, Len(Trim))) = LCase(Trim) Then Str = Mid$(Str, 1, Len(Str) - Len(Trim)) Else Check = False End If End If Loop ATrim = Str End Function




Reply With Quote