Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim ListGroups As IEnumerable(Of IGrouping(Of String, ListViewItem)) _
= ListView1.Items.Cast(Of ListViewItem).GroupBy(Function(Obj) Obj.Text)
Dim LVIs As ListViewItem() = (From IG As IGrouping(Of String, ListViewItem) In ListGroups
Let posVal As Integer = ReturnTotal(IG, True)
Let negVal As Integer = ReturnTotal(IG, False)
Select New ListViewItem(New String() {IG.Key, CStr(posVal - negVal), ""})).ToArray
ListView2.Items.AddRange(LVIs)
End Sub
Private Function ReturnTotal(IG As IGrouping(Of String, ListViewItem), ReturnPositives As Boolean) As Integer
Dim ItemIsPositive As Func(Of ListViewItem, Boolean) = Function(LVI) LVI.ForeColor = Color.Green
Dim ItemIsNegative As Func(Of ListViewItem, Boolean) = Function(LVI) LVI.ForeColor = Color.Red
Return If(ReturnPositives, IG.Where(ItemIsPositive), IG.Where(ItemIsNegative)).Select(Function(x) Integer.Parse(x.SubItems(1).Text)).Aggregate(Function(a, b) a + b)
End Function