Reputation: 13283
I'd like to know if it is possible for the richtextbox or textbox multi lines to print in a new line upon receiving a certain character like "Z"?
I'm having a big time problem in getting values from a richtextbox. My microcontroller is sending a string in a non-constant speed to the C# program so any way that I use to extract the numbers from the string in a richtextbox is useless I think.
If my circuit sends this kind of string: Sensor1: 0.10 meter/s \nSensor2: 0.50 meter/s and then the c# program receives it and detects the \n, the next characters/string will be printed in a new line until it detects the another \n.
Is this possible? if not, what way can I use?
Upvotes: 1
Views: 357
Reputation: 1934
Assume you have a RichTextBox Control named RichTextBox1
. Just replace your \n
with ControlChars.Lf
Code in Visual Basic
RichTextBox1.Text = RichTextBox1.Text.Replace(ControlChars.Lf, "\n")
Code in C#
RichTextBox1.Text == RichTextBox1.Text.Replace(ControlChars.Lf, "\n")
You need to reference Microsoft.VisualBasic
, parent of ControlChars.Lf
. That goes without saying.
Upvotes: 1