画蛇添足一下,考虑到dr2可能没有找到的情况,添加一个判断
Dim T As StringDim dr1,dr2 As DataRow
Dim drs As List(Of DataRow)drs = DataTables("表A").Select("[品名] = 'PD01'")for Each dr1 in drs T = "[品名] = '" & dr1("品名") & "'And [规格] = '" & dr1("规格") & "'" dr2 = DataTables("表B").Find(T) if dr2 IsNot Nothing then dr2("客户")="PPP" end ifNext