AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,099
- Office Version
- 2019
- 2010
- Platform
- Windows
I have a need to remove any leading or trailing VBCRLF characters from a string.
What I have is this, but there may be a better way ?
Then do something similar to the start of the string.
But I wonder if that's the best/fastest approach ?
Must also handle a single CR or LF.
What I have is this, but there may be a better way ?
VBA Code:
If Len(str) > 0 Then
Do
Select Case Asc(Right(str, 1))
Case 13, 10
str = Left(str,Len(str)-1)
Case Else
Exit Do
End Select
Loop Until Len(str) = 0
End If
TheTrim = str
But I wonder if that's the best/fastest approach ?
Must also handle a single CR or LF.