'vb.net RichTextBox Environment.NewLine not showing CR only LF
After I run the following in vb.net I am only showing a "LF" and no "CR" (notepad++)
When I copy and paste or open the saved file in notepad it only returns on one line. Digging deeper I notice there are no CR and only LF. Any advice on why the CR is not showing up? The file looks great in RichTextBox.
RichTextReport.AppendText("Printer Report:" + Environment.NewLine)
RichTextReport.AppendText(sDate + " : " + sTime + Environment.NewLine)
RichTextReport.AppendText("something")
RichTextReport.AppendText(Environment.NewLine)
Solution 1:[1]
These are the character sequences to create a new line:
- vbCr is the carriage return (return to line beginning),
- vbLf is the line feed (go to next line),
- vbCrLf is the carriage return / line feed (similar to pressing Enter)
You can also call vbNewLine as well.
Solution 2:[2]
Please replace Environment.NewLine with Convert.ToChar(10)
Example:
RichTextReport.AppendText("Printer Report:" & Convert.ToChar(10))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pieter de Vries |
| Solution 2 | Ethan |
