Solved

remove trailing carriage return(s) VbCrLf

Posted on 2004-03-24
8
1,657 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 4

Expert Comment

by:learning_t0_pr0gram
ID: 10672873
how about..

Right(MyString, 6) = Replace(Right(MyString, 6), vbcrlf, "")
0
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 code to programmatically convert pdf to excel 21 86
VBA open file from excel cell 4 42
Copy a row 12 61
using web browser with BING 40 119
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

785 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