以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  分隔符的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107750)

--  作者:douglas738888
--  发布时间:2017/10/9 11:43:00
--  分隔符的问题

请教老师,下面代码,生成的“指定质量评价人”的时候怎样让分隔符自动调整,不出现空值,因为表A的三列是随机填入内容的

 

例子        

                   表A                                     表B                               表B应该实现

       校对      审核      批准                   指定质量评价人

                   老李     老张                    ,老李,老张                        老李,老张

       老马                 老张                    老马,,老张                        老马,老张

       老马       老李                              老马,老李,                        老马,老李

       老马       老李     老张                   老马,老李,老张                   老马,老李,老张

 

If e.DataCol.Name = "校对" OrElse e.DataCol.Name = "审核" OrElse e.DataCol.Name = "批准" Then
   Dim pdr As DataRow = DataTables("表B").find("任务索引 = \'" & e.DataRow("任务索引") & "\'")
        If pdr IsNot Nothing Then
            Dim str As String = ""
            Dim str1 As String = ""
            Dim str2 As String = ""
            For Each drr As DataRow In DataTables("表A").Select("任务索引 = \'" & e.DataRow("任务索引") & "\'")
                str &  = drr("校对") & "," 
                str1 & = drr("审核") & "," 
                str2 & = drr("批准")  
            Next
            pdr("指定质量评价人") = (str & str1 & str2)\'.trim(chr(13),chr(10))
    End If
End If


--  作者:有点甜
--  发布时间:2017/10/9 11:51:00
--  
If e.DataCol.Name = "校对" OrElse e.DataCol.Name = "审核" OrElse e.DataCol.Name = "批准" Then
    Dim pdr As DataRow = DataTables("表B").find("任务索引 = \'" & e.DataRow("任务索引") & "\'")
    If pdr IsNot Nothing Then
        Dim str As String = ""
        Dim str1 As String = ""
        Dim str2 As String = ""
        For Each drr As DataRow In DataTables("表A").Select("任务索引 = \'" & e.DataRow("任务索引") & "\'")
            str &  = iif(drr.isnull("校对"), "", drr("校对") & ",")
            str1 & = iif(drr.isnull("审核"), "", drr("审核") & ",")
            str2 & = iif(drr.isnull("批准"), "", drr("批准") & ",")
        Next
        pdr("指定质量评价人") = (str & str1 & str2).trim(",")
    End If
End If