Solved

remove trailing carriage return(s) VbCrLf

Posted on 2004-03-24
8
1,653 Views
Last Modified: 2008-02-20
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
Comment
Question by:NO_CARRIER
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10672843
you can use this
MyString =Left(MyString , Len(MyString ) - 2)
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10672845
-2 is because vbcrlf is infact 2 characters
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 10672862
... 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
 
LVL 4

Expert Comment

by:learning_t0_pr0gram
ID: 10672873
how about..

Right(MyString, 6) = Replace(Right(MyString, 6), vbcrlf, "")
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:learning_t0_pr0gram
ID: 10672927
MyString = Replace(Right(Text1.Text, 6), vbCrLf, "")
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 6) & MyString


..try that
0
 
LVL 15

Accepted Solution

by:
unknown_routine earned 65 total points
ID: 10672981


if right (MyString ,  2)=vbcrlf then

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

end if
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10672997
Can you just do

MyString = Replace(MyString, vbCrLf, "")
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 10673013
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now