I am using a Rich TextBox in VB.NET and passing to a StringBuilder. I need to replace the New Line character from the TextBox with either a space or a comma. Problem is the standard codes for new line don't seem to be picking up this New Line character in this case. Is there a specific character used in Rich TextBoxes as the New Line? Any help or suggestions will be appreciated.
I was able to figure it out. You have to use ControlChars.Lf so the code would be along the lines of the following:
RichTextBox1.Text = RichTextBox1.Text.Replace(ControlChars.Lf, ",")
You can try Environment.NewLine
as a language-agnostic constant for a true newline (you should try to avoid language-specific constants and functions when possible).
RichTextBox1.Text = RichTextBox1.Text.Replace(Environment.NewLine, ",")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With