Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1778
  • Last Modified:

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?
0
NO_CARRIER
Asked:
NO_CARRIER
  • 3
  • 2
  • 2
  • +1
1 Solution
 
unknown_routineCommented:
you can use this
MyString =Left(MyString , Len(MyString ) - 2)
0
 
unknown_routineCommented:
-2 is because vbcrlf is infact 2 characters
0
 
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
unknown_routineCommented:


if right (MyString ,  2)=vbcrlf then

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

end if
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now