增加个名为统计的表,包括姓名和收入两列
增加一个按钮,按钮代码:
Dim dict As New Dictionary(Of String, Double)
For Each c As Col In Tables("收入之和").Cols
If c.Name.StartsWith("月总收入_") = False AndAlso c.Name.Contains("_姓名") Then
For Each r As Row In Tables("收入之和").Rows
If r.IsNull(c.Name) = False Then
If dict.ContainsKey(r(c.Name)) Then
dict(r(c.Name)) = dict(r(c.Name)) + r(c.Name.Replace("姓名", "金额"))
Else
dict.Add(r(c.Name), r(c.Name.Replace("姓名", "金额")))
End If
End If
Next
End If
Next
DataTables("统计").DataRows.Clear
For Each key As String In dict.Keys
Dim dr As DataRow = DataTables("统计").AddNew()
dr("姓名") = key
dr("收入") = dict(key)
Next
MainTable = Tables("统计")