NewLine in a TextBox

I have a text box on a form that im appending text to. How do i put a new line in.

Code:
Textbox1.AppendText("blah")

I want to put a Return before and make it its own line.


Answer this question

NewLine in a TextBox

  • Jason Weiss

    You made a mistake in the command.
    You should use Environment.NewLine instead of Enviroment.NewLine (missing the 'n').

    Grtz, Tom.



  • MikeGB621234

    You should actually use Environment.NewLine, just in case your code gets run on a system one day where the newline is not CrLf.



  • BatesManty

    HoundsOfHell asked the same question just now within the following post (^_^ ):

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=360129&SiteID=1

    If i'm not mistaken, by adding the "vbCr" or "ControlChars.CrLf" commands to you AppendText command, you should be able to start a NewLine (if the TextBox in question has the "MultiLine" property set to True).

    Maybe you could try that.


  • Larry Beck

    cgraus wrote:

    You should actually use Environment.NewLine, just in case your code gets run on a system one day where the newline is not CrLf.



    I tried that but i gave me an error

  • jebz

  • Micke Andersson

    When i used the "Enviroment.Newline" command it gave me an error saying the "Enviroment is not Declared".

    Ive been using "ControlChar.CrLf"

  • adam kromm

    What would the actual line of code be

    Textbox1.appendtext("blah" & vbCR)

    or

    Textbox1.appendtext("blah" & ControlChars.CrLf)

    something like that

  • Aaron Engel

    Hmmm. That's interesting. I've just been introduced to the VB.NET environment, so i'm basically learning new commands and properties via posts like these.

    At the moment i've been using the "vbCr" command a lot. I've tried the Environment.NewLine command you mentioned and the result is the same.

    If TextBox2.Text <> "" Then TextBox1.AppendText(TextBox2.Text & Environment.NewLine)

    You mentioned a few posts back that there is a possibility on a system the newline is not CrLf. How can you tell Is there a way of verifying it


  • Lenitcha

    i used from his example

    TextBox1.AppendText(TextBox2.Text & ControlChars.CrLf)


  • NewLine in a TextBox