Dim 表数据集 As New List(Of String)
For Each 行 As Row In Tables("表C").rows
表数据集.Add(行("第一列") & "," & 行("第二列") & "," & 行("第三列") & "," & 行("第四列") & "," & 行("第五列") & "," & 行("第六列"))
Next
Dim 结果集 As New List(Of String)
For i As Integer = 0 To 表数据集.Count - 1
Dim 序列 =
From 元素1 In 表数据集(i).split(",")
From 元素2 In 表数据集(i).split(",")
From 元素3 In 表数据集(i).split(",")
Where 元素1 <> 元素2 AndAlso 元素1 <> 元素3 AndAlso 元素2 <> 元素3
Select 元素1 & "," & 元素2 & "," & 元素3
Dim 组合集 As New List(Of String)
For Each 元素 As Object In 序列
组合集.Add(String.join(",", CStr(元素).split(",").OrderBy(Function(子元素) 子元素)))
Next
For Each 组合 As String In 组合集.distinct
Dim lst As New List(Of String)
If 表数据集.skip(i + 1).where(Function(表数据) 表数据.split(",").Intersect(组合.split(",")).count = 3).count > 0 Then
结果集.Add(i & ":" & 组合)
End If
Next
Next
结果集 = 结果集.groupby(Function(元素) 元素.split(":")(0)).
select(Function(元素1) 元素1.key & ":" & String.join("/", 元素1.select(Function(元素2) 元素2.split(":")(1)))).tolist
' Output.Show(String.join(vbcrlf, 结果集))
DataTables("表C").ReplaceFor("第七列", "")
For Each 结果 As String In 结果集
Tables("表C").rows(结果.split(":")(0))("第七列") = 结果.split(":")(1)
Next