LF & CR in Textbox

A

Armon Myrick

The textbox will not goto next line when addindg a new string or VBCrLf.
All the lines are put on the first line of the textbox. I need to put a
textfile in the Textbox using streamreader. Wordwrap=false, multiline=True,
scrollbars = both. Sample code is included. Using it as a test bed.
References are correct.
Dim sr As StreamReader = New StreamReader("\storage
card\cncmgr\setting.txt")

Dim input As String

input = sr.ReadLine()

While Not input Is Nothing

TextBox1.Text = input + vbCrLf

input = sr.ReadLine()

End While

sr.Close()

A far as I can see, this should work.

Thanks for any help

A. Myrick
 
R

Rod O.

Hey Armon,

Curiously, you require /r/n. That is
o if there is such a thing you need vbLfCr
o or ^M^J (control-M control-J)
o or 0x000D 0x000A

Hope this helps,

Rod O.
 
A

Alex Feinman [MVP]

Set TextBox.Multiline to True
The line terminator is VbCrLf (or "\r\n" in C#)
 
B

Benjamin Lukner

Armon said:
While Not input Is Nothing
TextBox1.Text = input + vbCrLf

The error is that you REPLACE the string in the text box.
Try this:
TextBox1.Text += input + vbCrLf
input = sr.ReadLine()
End While

Kind regards,

Benjamin Lukner
trinomix GmbH
 
A

Armon Myrick

One question? Wouldn't you exceed the max characters on a single line. I
can't have the wordwrap on because the text file is a code file for a CNC
machine and each line is specific and has to be on it's own line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top