以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  循环语句中字符清空使用  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=178754)

--  作者:otterlike
--  发布时间:2022/7/19 11:07:00
--  循环语句中字符清空使用
老师好!我写了一个循环代码,希望从b To a Step -1每次执行完毕,字符(id = ""变成空值重新使用,出来的结果是id的值在不断累加,请问如何修改?
Dim a As Integer = 0 \'完善采购合同中到港时间字段
Dim b As Integer = Tables("采购合同").rows.Count - 1
For i As Integer = b To a Step -1
    Tables("采购合同").Position = i
    
    Dim Filter1 As String
    If Tables("采购合同.物流计划副表采购合同").Rows.Count = 0 Then 
        Filter1 = "[_Identify] is null" 
    Else
        Dim ids1 As String
        For Each dr As Row In Tables("采购合同.物流计划副表采购合同").Rows
            ids1 = ids1 & ",\'" & dr("指令单号") & "\'"
        Next
        ids1 = ids1.Trim(",")
        Filter1 = "[采购物流计划指令单号] In (" & ids1 & ")"
    End If
    Tables("运输单副表采购合同").Filter = Filter1
    
    Dim id As String 
    For Each dr As Row In Tables("运输单副表采购合同").Rows
        id = id & "," & dr("目的地到港时间") 
    Next
    
    Tables("采购合同").rows(i)("到港时间") = id
    id = ""
Next

--  作者:有点蓝
--  发布时间:2022/7/19 11:44:00
--  
Dim id As String = ""