Try this. Tested now...
This is assuming you want the last entry for every distinct badge. Using your text file, i found 12 lines...Code:Dim lines() As String = IO.File.ReadAllLines(path) Dim distinctBadges() As String = lines.Select(Function(l) l.Substring(0, 13)).Distinct.ToArray Dim lastLines As New List(Of String) For Each db As String In distinctBadges For x As Integer = 0 To lines.GetUpperBound(0) - 1 If lines(x).StartsWith(db) And Not lines(x + 1).StartsWith(db) Then lastLines.Add(lines(x)) End If Next Next




Reply With Quote
