Foxtable(狐表)用户栏目专家坐堂 → 求助,如何获取表中有重复值集合?


  共有10953人关注过本帖树形打印复制链接

主题:求助,如何获取表中有重复值集合?

帅哥哟,离线,有人找我吗?
mr725
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2011/3/3 14:26:00 [显示全部帖子]

以下是引用狐狸爸爸在2011-3-3 12:00:00的发言:
Dim Lst1  As List(of String)= DataTables("表A").GetUniqueValues("第一列")
Dim Lst2  As List(of String)= DataTables("表A").GetUniqueValues("第二列")
For Each v As String In Lst2
    If Lst1.Contains(v) = False Then
        lst1.Add(v)
    Next
Next

这个不对呀,不是第一列=第二列的行,而是:第一列重复 且 第二列重复的行


 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2011/3/3 14:47:00 [显示全部帖子]

我的复杂些, 看看楼主是不是要这个结果:

'''
Tables("表").Select(0,Tables("表").cols("列1").Index)
Syscmd.Filter.ShowSameValues()
Dim urp  As List(of String)= DataTables("表").GetUniqueValues("","列2")

Dim rp,rp1 As String
rp1 = ","

For i As Integer = 0 To Tables("表").count -1
    Dim r As Row = Tables("表").Rows(i)
    Dim drs As List(Of DataRow)
    drs = DataTables("表").Select("[列2] = '" & _
    Tables("表").Rows(i)("列2") & "' and [列1] = '" & Tables("表").Rows(i)("列1") & "'")
    If drs.count >= 2 And rp1.contains("" & Tables("表").Rows(i)("列2") & "") = False
        rp1 = rp1 & "," & Tables("表").Rows(i)("列2")

        output.show(Tables("表").Rows(i)("列1") & "  "  & Tables("表").Rows(i)("列2"))
    End If
Next

 

还没有完全对····

[此贴子已经被作者于2011-3-3 15:33:26编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2011/3/3 16:35:00 [显示全部帖子]

这样ok啦:

 

'''
Tables("表").Select(0,Tables("表").cols("列1").Index)
Syscmd.Filter.ShowSameValues()
Dim rp1 As String
rp1 = ","
For i As Integer = 0 To Tables("表").count -1
    Dim r As Row = Tables("表").Rows(i)
    Dim drs As List(Of DataRow)
    drs = DataTables("表").Select("[列2] = '" & _
    Tables("表").Rows(i)("列2") & "' and [列1] = '" & Tables("表").Rows(i)("列1") & "'")
    For Each dr As DataRow In drs
        If  rp1.contains("," & CurrentTable.Rows(i)("列1")) = False
            rp1 = rp1 & "," & CurrentTable.Rows(i)("列1")
            output.show(CurrentTable.Rows(i)("列1") & "  "  & CurrentTable.Rows(i)("列2"))
        End If
        Exit For
    Next
Next


 回到顶部