Displaying list of text in a TextBox

I'm a novice programmer and I have a very basic question. I am trying to display text in a TextBox, with one caveat. I need to be able to insert "carriage returns" or force the text onto a new line. I am using the text box to display the results of a numbered list. How can this be done

As a work around I am using Word to display the results, but ideally the application needs to be able to display the results in a text box.

Thank you for any help you can provide.



Answer this question

Displaying list of text in a TextBox

  • webcliff

    Brilliant! That did it. The vbCrLf was the command I was looking for. Thank you so much. This has been frustrating me for over a week.
  • AustinH100

    I tried adding evironment.NewLine and I'm getting an error: 424 Run-time Error. Object required.

    I'm not much of a programmer. Do I need to substitute an object for the word "environment" in the line of code you suggested


  • eyal berman

    You can set the multiline attribute to true.

  • Jo?ko

     

    vbCrLf and Environment.NewLine produce the same result; specifically, a carriage return and line feed characters. Should the .NET framework be implemented on, say, a unix platform, then they may (would) be different. Lookup the .NewLine property in Help.

    Note that if you are having issues with Environment.NewLine, then you may have other problems, too: by default, Environment.Newline should be available to you for use.



  • FuZi0n

    vbCrLf works fine for me, what is the difference between the two

    str = item1 & vbcrlf & item2 & vbcrlf



  • ZeroZero

    I've done that, but I need to some how force a new line after each list item. Curruently I have a numbered list strung together. I need each numbered item to appear on it's own line. Each lsit item maybe 1 or more lines in length. Any thoughts
  • Michael Hamling

    ''If it were me I would make the textbox multi line then do something like this:

    Private Const LINE_ITEM_FORMAT as String = "{0}) {1}" & vbCrLf

    Private itemList As String

    itemList += String.Format(LINE_ITEM_FORMAT, 1, "the first item")
    itemList += String.Format(LINE_ITEM_FORMAT, 2, "the second item")
    itemList += String.Format(LINE_ITEM_FORMAT, 3, "the third item")
    itemList += String.Format(LINE_ITEM_FORMAT, 4, "the forth item")

    TextBox1.Text = itemList

    ''If you list is broken up by commas or some other delimiter you can use String.Split to create an array of items you can loop though.

  • Mandana

    Check this out:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemenvironmentclassnewlinetopic.asp

    It seems like you should be able to use this, but I've never tried it in a text box. Did you set the textbox to allow multiline text


  • Ray Seppala

    How do you convert your numbered list into a string You could of vbCrLf.

  • Vista

    This trick has worked for me regarding Tooltips and I think that it can work with text boxes as well. You can use the "environment.NewLine" command to start a new line. You must string it together just as if it was a normal string.

    Example:

    Textbox.text = "This example will start a new line" & environment.NewLine & "NOW"


  • Displaying list of text in a TextBox