'Remove the consecutive carriage return and space at the beginning and end of the string.
Function trimvbcrlf (STR)
Trimvbcrlf = rtrimvbcrlf (ltrimvbcrlf (STR ))
End Function
'Remove the consecutive carriage returns and spaces starting with a string.
Function ltrimvbcrlf (STR)
Dim POs, isblankchar
Pos = 1
Isblankchar = true
While isblankchar
If mid (STR, POs, 1) = "" then
Pos = POS + 1
Elseif mid (STR, POs, 2) = vbcrlf then
Pos = POS + 2
Else
Isblankchar = false
End if
Wend
Ltrimvbcrlf = right (STR, Len (STR)-pos + 1)
End Function
'Remove the consecutive carriage return and space at the end of the string.
Function rtrimvbcrlf (STR)
Dim POs, isblankchar
Pos = Len (STR)
Isblankchar = true
While isblankchar and Pos> = 2
If mid (STR, POs, 1) = "" then
Pos = pos-1
Elseif mid (STR, pos-1, 2) = vbcrlf then
Pos = pos-2
Else
Isblankchar = false
End if
Wend
Rtrimvbcrlf = rtrim (left (STR, POS ))
End Function