Delete the First Line in a TextBox - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

delete first line in visual basic

The following example describes how to remove the first line of a textbox in visual basic .net

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim b As String() = Split(TextBox1.Text, vbNewLine)
        TextBox1.Text = String.Join(vbNewLine, b, 1, b.Length - 1)
    End Sub

To remove the last line in a textbox use the following code:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim b As String() = Split(TextBox1.Text, vbNewLine)
        TextBox1.Text = String.Join(vbNewLine, b, 0, b.Length - 1)
    End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.