应用时,应该把输出的语句删除
Dim t1 As Table = Tables("表A")
Dim t2 As Table = Tables("表B")
Dim nr1,nr2 As String
Dim sl1,sl2,sl3 As Integer
For Each r As Row In t1.Rows
nr1=r("第一列")
nr2=r("第二列")
If not r.IsNull("第一列") Then '不为空行的情况下进行处理
sl1=cint(nr2)
sl2=t2.Compute("count(第一列)","第一列='" & nr1 & "'") '计算表B中出现的次数
If sl1>sl2 Then
output.show(nr1 & "应该增加:" & sl1-sl2 & "条")
For j As Integer=1 To sl1-sl2 '数量差 sl1-sl2
Dim r2 As Row = t2.AddNew '增加新行
r2("第一列")=nr1 '写入数据
Next
ElseIf sl1<sl2 Then
output.show(nr1 & "应该减少:" & sl2-sl1 & "条")
For j As Integer =1 To sl2-sl1
sl3=t2.Compute("max(_Identify)","第一列='" & nr1 & "'") '查找最大的行号,为删除最后一行做准备
'sl3=t2.FindRow("[第一列]='" & nr1 & "'",sl2-1)
t2.Rows(sl3-1).Delete()
Next
Else
output.show(nr1 & "应该不变")
End If
End If
Next