remove trailing carriage return(s) VbCrLf

sometimes (but not always) at the end of my multiline textbox there are carriage returns created... how can I remove trailing carriage returns?

something like:
MyString = Replace(MyString, vbCrLf, "  ")
and Rtrim (MyString, 1)
combined?
LVL 1
NO_CARRIERAsked:
Who is Participating?
 
unknown_routineConnect With a Mentor Commented:


if right (MyString ,  2)=vbcrlf then

 MyString =Left(MyString , Len(MyString ) - 2)

end if
0
 
unknown_routineCommented:
you can use this
MyString =Left(MyString , Len(MyString ) - 2)
0
 
unknown_routineCommented:
-2 is because vbcrlf is infact 2 characters
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
NO_CARRIERAuthor Commented:
... how would I be able to figure out if the last character is indeed a carriage return?... (so it will only remove it if it's there... and not cut into the actual string.)
0
 
learning_t0_pr0gramCommented:
how about..

Right(MyString, 6) = Replace(Right(MyString, 6), vbcrlf, "")
0
 
learning_t0_pr0gramCommented:
MyString = Replace(Right(Text1.Text, 6), vbCrLf, "")
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 6) & MyString


..try that
0
 
EDDYKTCommented:
Can you just do

MyString = Replace(MyString, vbCrLf, "")
0
 
NO_CARRIERAuthor Commented:
that will replace all the carriage returns in the text... this is in a multi-line textbox.
I only want to remove trailing carriage returns at the END of the string.
0
All Courses

From novice to tech pro — start learning today.