Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Carriage Return from end of line 1

Status
Not open for further replies.

TheLad

Technical User
Aug 3, 2001
3,846
GB
Guys

I have written a script that exports data to a file in a comma-separated CSV format but one particular entry always has a carriage return on the end of it. As a result, the CSV file has the contents over two lines instead of one.

Please can someone advise how I can take a string and strip the carriage return, even if it is just removing the last character of the value (which is more than likely where the carriage return is).

Thanks

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Thanks for your reply. The script you have posted should do exactly what I am looking for however I am still getting rectangles in the file at the end of the string which Excel is treating as carriage returns.

Any ideas?

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
I also tried the Replace code with " " at the end and it would appear that the code is working but not removing the rectangles as the replace occurs before the rectangles...

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
I managed to get it sorted by removing the last two characters from the string not just the last one. Thanks for your help!

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
YourString=Replace(YourString,vbCrLf,"")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV is right, you have a carriage return+line feed, so 2 characters need to be removed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top