以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  提取填充重复或顺序改变  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=163032)

--  作者:yuyu060712
--  发布时间:2021/4/21 14:18:00
--  提取填充重复或顺序改变

Dim Cols1() As String = {"工号","件号","零件图号","名称及规格","单台数量","合计数量","材质名称","材检编号","工艺路线","到位日期","到位数量","入库日期","入库数量","序1","序2","序3","序4","序5","序6","序7","序8","序9","序10","序11","序12","序13","序14","序15","序16","序17","序18","序19","序20"}
Dim Cols2() As String = {"工号","件号","零件图号","名称及规格","单台数量","合计数量","材质名称","材检编号","工艺路线","到位日期","到位数量","入库日期","入库数量","序1","序2","序3","序4","序5","序6","序7","序8","序9","序10","序11","序12","序13","序14","序15","序16","序17","序18","序19","序20"}
For Each dr1 As DataRow In DataTables("零件台账").Select("[工号] > \'0\'")
    Dim dr2 As DataRow = DataTables("零件明细").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next

老师,以上代码无法判断重复值,用了重复值得判断代码后,顺序要变

Dim Cols3() As String = {"试样编号","技术条件","屈服强度","抗拉强度","伸长率","收缩率","冲击功","硬度","晶粒度","弯曲","组织","试样状态"}
Dim Cols4() As String = {"试样编号","技术条件","屈服强度","抗拉强度","伸长率","收缩率","冲击功","硬度","晶粒度","弯曲","组织","试样状态"}
For Each dr1 As DataRow In DataTables("试样台账").Select("[技术条件] > \'0\'")
    Dim dr2 As DataRow = DataTables("试样性能").Find("试样编号 = \'" & dr1("试样编号") & "\'")
    If dr2 Is Nothing Then
        dr2 = DataTables("试样性能").AddNew()
    End If
    For i As Integer = 0 To Cols3.Length -1
        dr2(Cols4(i)) = dr1(Cols3(i))
    Next
Next

请教下需要怎么改?


--  作者:有点蓝
--  发布时间:2021/4/21 14:22:00
--  
For Each dr1 As DataRow In DataTables("试样台账").Select("[技术条件] > \'0\'","_sortkey") 

如果没有_sortkey列,改为_Identify