How do I add a newline to a windows-forms TextBox?

后端 未结 14 522
温柔的废话
温柔的废话 2021-01-01 09:37

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 ha

14条回答
  •  遥遥无期
    2021-01-01 10:37

    Took this from JeffK and made it a little more compact.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        Dim Newline As String = System.Environment.NewLine
    
        TextBox1.Text = "This is a test"
        TextBox1.Text += Newline + "This is another test"
    
    End Sub
    

提交回复
热议问题