'Delete last line in a RichTextBox in VB .NET

I've been search and I can't found an answer that works, I need to remove (delete) the last line in a RichTextBox1 in vb.net, I mean remove last line and 'breakline' too, but only the last, no others.

Can anyone help me?



Solution 1:[1]

Try this:

Dim myList As List(Of String) = richTextBox1.Lines.ToList()
If myList.Count > 0
    myList.RemoveAt(myList.Count - 1)
    richTextBox1.Lines = myList.ToArray()
    richTextBox1.Refresh()
End If

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1