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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip Line Feeds from String 2

Status
Not open for further replies.

aco636

IS-IT--Management
Nov 25, 2003
212
GB
Hi there

As always any help gratefully received.
Am writing script to create a csv file based on data from a DB. the script is something like;

strComment = objRc1.Fields("CommentField")
csv.Write strComment

The problem I have is, as I try to add a new record to my csv file, things get messed up because the strComment has line feeds within original data and strComment is then placed on multiple lines.

What I would like to do is have one long text string with no line feeds, etc. Was hoping there is a way without having to write objRc1.Fields("CommentField")
to temp file and then set the contents of temp file to strComment.

REgards ACO
 
Hello aco636,

Can do it like this.
[tt]
strComment=replace(strComment,chr(10),"")
[/tt]
regards - tsuji
 
If it is purely an issue of having line feeds within the field, you could try:

strComment = Replace(objRc1.Fields("CommentField"), vbCrLf, "")



[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks Chaps

New there had to be a simple way to do this, both suggestions work. Thanks for saving me hours trawling the web.

Regards ACO
 
Generally you only encounter the carriage return and line feed combinations like this:

CHR(13) & CHR(10) 'same as vbCrLf
CHR(10)
CHR(13) 'probably rare
CHR(10) & CHR(13) 'rare, someone didn't put in right order

The exact code used may depend of the language which created it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top