I am trying to add a line of text to a TextBox component in VB.net, but I cannot figure out for the life of me how to force a new line. Right now it just adds onto what I have already, and that is not good.
I have tried copying the actual linebreaks, didn't work. I tried AppendText(), didn't work.
How on earth do I do this? It is multiline already.
Of course, there are situations in which there is need to add line breaks. You can do so by simply hitting Shift + Return or Shift + Enter , respectively.
Step 1: Create a windows form. Step 2: Drag the TextBox control from the ToolBox and drop it on the windows form. You can place TextBox anywhere on the windows form according to your need. Step 3: After drag and drop you will go to the properties of the TextBox control to set the Multiline property of the TextBox.
Try using Environment.NewLine
:
Gets the newline string defined for this environment.
Something like this ought to work:
textBox.AppendText("your new text" & Environment.NewLine)
Try something like
"Line 1" & Environment.NewLine & "Line 2"
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