Does anyone know if there's a string function that removes new lines from a string (where return has been hit to start a new paragraph) It's kind of like the Trim functions I'm looking for, but these only work with trailing spaces, not where a new line has been started.
Cheers!
Keith

String Functions
Sundararajan
Your right. I didn't pay attention to on what forum it was:)
karande23
Hey man,
Try the Replace() function. Just replace all the vbCrLf in the string with "" and that will remove them.
daimaku
Derek Smyth
Hi Keith
Below example is one option to remove carriage returns (replacing with a space). Just change it to a function and pass your string to it as a parameter
Public Sub mysub()
Dim MyString As String
MyString = "first line - " & Chr$(13) & "second line - " & Chr$(13) & "third line - "
Debug.Print MyString
While InStr(1, MyString, Chr$(13)) > 0
Mid$(MyString, InStr(1, MyString, Chr$(13)), 1) = " "
Wend
Debug.Print MyString
End Sub
xr280xr
myString.Replace(Environment.NewLine.ToCharArray(),
String.Empty.ToCharArray())nichowave
Cheers for that. My final solution below. Basically, it's a text box where it is possible for the user to hit return and begin a new paragraph if they wish, but where I was writing that input to could not have new lines.
Replace(Cont.Value, vbNewLine, " ")
Cheers, guys!
PeterZ
SimonOng
Hi,
I unmarked CetinBasoz post as the answer as the code given is VB.NET and not VBA.