For Each drb As DataRow In DataTables("表b").datarows
Dim fdr As DataRow = DataTables("表a").Find("领料部门 = '" & drb("领料部门") & "'")
If fdr Is Nothing Then
fdr = DataTables("表A").addnew
fdr("领料部门") = drb("领料部门")
fdr("金额") = drb("金额")
fdr("张数") = drb("张数")
End If
Next
For Each dra As DataRow In DataTables("表A").datarows
Dim fdr As DataRow = DataTables("表B").Find("领料部门 = '" & dra("领料部门") & "'")
If fdr IsNot Nothing Then
dra("张数差异") = dra("张数") - fdr("张数")
dra("金额差异") = dra("金额") - fdr("金额")
Else
dra("科室差异") = "B表无该部门"
End If
Next