Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
我要找出零件编号为A,完成日期为最近的行,零件编号为B,完成日期为最近的行.......
是否采用For Each 语句,代码怎么写?
Dim Filter As String = "零件编号 = ''"
Dim Products As List(Of String)
Products = DataTables("表A").GetValues("零件编号") '找出不同的零件编号
For Each Product As String In Products
Filter = Filter & " And "
Filter = Filter & "(零件编号 = '" & Product & "' AND 完成日期 = '" & Max(完成日期) & "')"'找出不同零件编号的最近完成日期行
Next
If Filter > "" Then
Tables("表A").Filter = Filter '筛选出不同零件编号的最近完成行
End If
老师,上述代码的思路是否正确,帮我改一下代码?
Dim drs As List(Of DataRow) = DataTables("表A").Select("", "零件编号,完成日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs
If dr("零件编号") <> bh Then
rst.Add(dr)
bh = dr("零件编号")
Dim Filter As String = "工艺单号 = ''"
Filter = Filter & " And "
Filter = Filter & "工艺单号 = '" & dr("工艺单号") & "'"
If Filter > "" Then
Tables("表A").Filter = Filter
End If
End If
Next
筛选的结果生成的表是空的
Dim drs As List(Of DataRow) = DataTables("表A").Select("", "零件编号,完成日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs
If dr("零件编号") <> bh Then
rst.Add(dr)
bh = dr("零件编号")
MsgBox(bh)
Dim Filter As String = "工艺单号 = ''"
MsgBox(Filter)
Filter = Filter & " or "
MsgBox(Filter)
Filter = Filter & "工艺单号 = '" & dr("工艺单号") & "'"
MsgBox(Filter)
If Filter > "" Then
Tables("表A").Filter = Filter
End If
End If
Next
合成的Filter分别是如下内容,我希望的合成结果是工艺单='' or工艺单='A-03'or工艺单='B-03'
A 工艺单='' 工艺单='' or 工艺单='' or工艺单='A-03'
B 工艺单='' 工艺单='' or 工艺单='' or工艺单='B-03'