Question : Compare Listboxes

I have to listboxes. I need to check them for differences. How would I check them and if an item is new or different, display that item?

Answer : Compare Listboxes

Hi XGenwareS;

OK, try this.

Fernando
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Imports System.Text

Dim lb1 As List(Of String) = ListBox1.Items.Cast(Of Object)().Select(Function(s) s.ToString()).ToList()
Dim lb2 As List(Of String) = ListBox2.Items.Cast(Of Object)().Select(Function(s) s.ToString()).ToList()

Dim lbDiff As List(Of String) = lb1.Except(lb2).ToList()

Dim stringDiff As New StringBuilder()
lbDiff.ForEach(Function(s) stringDiff.Append(s & vbCrLf))

MessageBox.Show(stringDiff.ToString())
Random Solutions  
 
programming4us programming4us