表A,DataColChanged事件。
If e.DataCol.Name = "第二列" OrElse e.DataCol.Name = "第三列" Then
Dim dr As DataRow = e.DataRow
If dr.IsNull("第二列") OrElse dr.IsNull("第三列")
dr("第四列") = Nothing
Else
Dim dr1 As DataRow = DataTables("表B").Find("第一列 = '" & dr("第二列") & "' And 第二列 = '" & dr("第三列") & "'")
If dr1 IsNot Nothing Then '如果找到的话
Dim n As Integer = e.DataTable.Compute("Count(第二列)","第二列 = '" & dr("第二列") & "' And 第三列 = '" & dr("第三列") & "'")
dr("第四列") = GetPY(dr1("第一列"),True) & GetPY(dr1("第二列"),True) & Format(n,"000")
End If
End If
End If