P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Dec 29th, 2003 07:34 PM Post subject: Advanced Trim Function |
|
|
This might not be the best way but it works :
| 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 |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|