'=========================================================
'功能:排查多列重复内容
'参数dr:当前行
'参数clnames: 字符串,要排查的列,以 "第一列,第二列,...." 格式传入
'参娄 ecol: 当前列
'========================================================
Dim dr As DataRow=args(0)'参与比较的行
Dim cln As String=args(1)'参与比较的所有列
Dim ecol As String=args(2)'当前列
Dim clnames() As String
clnames=cln.split(",")
If dr(ecol)>"" Then
Dim Lclname As New List(Of String)
Dim str1 As new List(of String) '参与比较的内容
Dim str2() As String=dr(ecol).split(",") '将需要排查的当前列数据转为数组
Lclname.AddRange(clnames) '将数组加入集合,集合相比数组更灵活操作
Lclname.Remove(ecol) '去掉当前列
For Each s As String In Lclname '将比较的内容转化成数组
If dr(s)>"" Then
str1.AddRange(dr(s).split(","))
End If
Next
For Each s2 As String In str2 '如果找到重复的返回true
If str1.Contains(s2) Then
Return True
End If
Next
Else
Return False '空值不参与比较
End If
此主题相关图片如下:jdfw.gif
[此贴子已经被作者于2015/9/16 22:53:01编辑过]