建一个临时表,列:地区、职业、年度、数量
DataTables("表A").DataRows.Clear
For Each r As Row In Tables("委托代理人").Rows
Dim str As String = r("年度代理数量")
For Each s As String In str.replace(vbcr,"").split(vblf)
If s.Trim() = "" Then Continue For
Dim arr() As String = s.Split("-")
Dim dr As DataRow = DataTables("表A").Find("地区='" & r("地区") & "' And 职业 = '" & r("职业") & "' and 年度='" & arr(0) & "'")
If dr Is Nothing Then
dr = DataTables("表A").AddNew
dr("地区") = r("地区")
dr("职业") = r("职业")
dr("年度") = arr(0)
End If
dr("数量") = dr("数量")+val(arr(1))
Next
Next