以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]查找符合条件的行并赋值  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=59246)

--  作者:建筑人生
--  发布时间:2014/10/31 11:42:00
--  [求助]查找符合条件的行并赋值

 

 

 

 


    For Each r1 As Row In Tables("表").Rows  \'遍历表的各行
        If r1.IsNull("型号规格") =False Then           
           
                Dim dr As DataRow = DataTables("水卫工程量").Find("型号规格 = " & "\'" & r1("型号规格") & "\'" )
                If dr IsNot Nothing\'如果找到,则设置各列内容
                    r1("根数1")= dr("根数1")
                    r1("规格1")= dr("规格1")
                    r1("根数2")= dr("根数2")
                   
                    r1("规格2")= dr("规格2")
                End If
        End If
       
    Next

 

自己搞定了,

[此贴子已经被作者于2014-10-31 11:55:48编辑过]

--  作者:有点甜
--  发布时间:2014/10/31 11:50:00
--  
For Each r1 As Row In Tables("表").Rows  \'遍历表的各行
    If r1.IsNull("型号规格") =True Then   \'先判断型号1是否为空
        Dim x As String=r1("型号规格")
        Dim r As DataRow= DataTables("水卫工程量").Find("型号规格 = \'" & x & "\'") \'找出编号为03的产品
        If r IsNot Nothing Then
            r1("根数1") = r("根数1")
            r1("规格1") = r("规格1")
            r1("根数2") = r("根数2")
            r1("规格2") = r("规格2")
        End If
    End If
Next

--  作者:Bin
--  发布时间:2014/10/31 11:51:00
--  
代码没什么问题,报什么错?