Solved

remove trailing carriage return(s) VbCrLf

Posted on 2004-03-24
8
1,658 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 74
Validating VB6 Function 19 65
Added a column screws up code 5 63
VBA: copy range dynamically based on config sheet v2 3 50
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

821 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