Hi all.

If I have a multi-line textbox like this:

----

Line 1
Line 1
Line 1
Line 2
Line 2
Line 3

----

How do I remove lines that are the same as the line above?

This is my code:

vb.net Code:
  1. For i = 0 To txtTextResult.Lines.Count - 1
  2.             Dim sLine As String
  3.             sLine = txtTextResult.Lines(i)
  4.             Try
  5.                 Dim sNextLine As String = txtTextResult.Lines(i + 1)
  6.                 If sNextLine = sLine Then
  7.                     'Remove txtTextResult.Lines(i + 1)
  8.                    
  9.                 End If
  10.             Catch : Exit For : End Try 'When sLine is the last line, sNextLine can't be the line under it.
  11.         Next

I've already tried many things.

For example, this, which is not working:

vb.net Code:
  1. txtTextResult.Lines(i + 1).Remove(0) 'Remove ( startindex as integer)

Thanks.