View Single Post
Parody
Senior Member
 
Join Date: Jan 2013
Location: Rochester, MN
Posts: 1,517

Old September 14th, 2016, 07:06 PM
This is no different than pasting and copying back out of Notepad or another text editor, as the Text property of a RichTextBox reduces the text to a String. Whether that means line breaks disappear is going to depend on what the source program puts on the Clipboard vs. what Clipboard formats a RichTextBox can accept.

If you want to get rid of newlines, get rid of them:

Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    RichTextBox2.Text = RichTextBox1.Text.Replace(vbLf, "")
End Sub
or more thoroughly:

Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim convertedText As String = RichTextBox1.Text

    convertedText = convertedText.Replace((vbCr & vbLf), "")
    convertedText = convertedText.Replace((vbLf & vbCr), "")
    convertedText = convertedText.Replace(vbLf, "")
    convertedText = convertedText.Replace(vbCr, "")

    RichTextBox2.Text = convertedText
End Sub


Last edited by Parody; September 14th, 2016 at 07:41 PM.
Parody is offline   #2 Reply With Quote