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

Remove line breaks 2

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
PLease give me an idea how to remove line breaks and carriage returns characters from a line of text with VBScript. I assume it has to use Replace funtion. But what is the code for carriage return

thanks
 
The ASCII codes that you want to remove are 13 and 10 for CR and LF
 
newLine = Replace(oldLine, vbCrLf, "")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
just do it like PHV said and you'll get both 13 and 10 at the same time!

but if you just wanted to get one or the other, use Chr() not Char()
 
What is the issue with empty line ?
If you want accurate answer please ask detailed question.
Feel free to read either one FAQ in my sig.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Well a completely empty line would be just two vbCfLf in a row.

Or do you mean "empty" as a situation where you have only spaces and tabs on a line?
 
What I mean is how can I tell if the line is empty, and my empty I mean no text

thanks
 
Well that will make a much more difficult situation.

One way to approach it might be to use the Trim() function on each line before you remove the 13 10.
 
newLine = Trim(Replace(Replace(oldLine, vbCrLf, ""), vbTab, ""))
If Len(newLine) > 0 Then
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV, Sheco, thanks a lot for your responces, I really appreciate you taking your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top