参考代码
Dim str As String = "第一列,第二列"
Dim idx As String = ""
Dim ary() As String = str.Split(",")
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
For Each dr As DataRow In DataTables("表A").Select("第一列 is not null", str)
Dim flag As Boolean = False
For Each a As String In ary
If pdr IsNot Nothing AndAlso dr(a) <> pdr(a) Then
flag = True
End If
Next
If flag = False Then
count += 1
Else
'If count = 1 Then
idx &= pdr("_Identify") & ","
'End If
count = 1
End If
pdr = dr
Next
For Each a As String In ary
If pdr IsNot Nothing AndAlso Tables("表A").Rows(Tables("表A").Rows.count-2)(a) <> pdr(a) Then
idx &= pdr("_Identify") & ","
End If
Next
DataTables("表A").DeleteFor("_Identify not in (" & idx.trim(",") & ")")