以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  删除不重复的值,只保留重复的  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=134162)

--  作者:蓝蚂蚁
--  发布时间:2019/4/28 21:50:00
--  删除不重复的值,只保留重复的
搞了很久,还是搞不好,不搞了,开口向老师请叫算了!
表A结构及数据如下:
日期                            金额
2019-01-01                100
2019-01-01                100
2019-01-01                50
2019-01-01                50
2019-01-01                20
2019-01-01                10
.........................................
想把不重复的值删除,只保留重复的,结果就如下图
日期                            金额
2019-01-01                100
2019-01-01                100
2019-01-01                50
2019-01-01                50
不知道“删除“这个按钮的代码如何写?谢谢啦

[此贴子已经被作者于2019/4/28 21:52:31编辑过]

--  作者:有点甜
--  发布时间:2019/4/29 11:11:00
--  

显示唯一值,参考

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
        idx_temp &= dr("_Identify") & ","
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"