以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  重复值问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=99099)

--  作者:HJG_HB950207
--  发布时间:2017/4/12 17:30:00
--  重复值问题
表A如下列:
                                 
               车号       时间      重量      是否存在问题  
                A                                    
                A
                B
                B        
                :
                :
                :
                :

                时间为DATETIME 型, 是否存在问题为逻辑型

              请教老师代码:

                如果同一台车,在同一天,重量不同,则
                是否存在问题列显示为真。


         

--  作者:有点色
--  发布时间:2017/4/12 17:39:00
--  
Dim dt As DataTable = DataTables("表B")
For Each ary() As String In dt.GetValues("第一列|第二列")
    Dim drs As List(Of DataRow) = dt.Select("第一列 = \'" & ary(0) & "\' and 第二列 = \'" & ary(1) & "\'")
    Dim pdr As DataRow = Nothing
    Dim flag As String = False
    For Each dr As DataRow In drs
        If pdr IsNot Nothing AndAlso dr("第三列") <> pdr("第三列") Then
            flag = True
            Exit For
        End If
        pdr = dr
    Next
    For Each r As DataRow In drs
        r("第四列") = flag
    Next
Next