Foxtable(狐表)用户栏目专家坐堂 → [求助]多个多值字段拆分


  共有1663人关注过本帖树形打印复制链接

主题:[求助]多个多值字段拆分

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/15 18:27:00 [显示全部帖子]

Dim dt1 As DataTable = DataTables("表A")
Dim dt2 As DataTable = DataTables("表B")
For Each dr As DataRow In dt1.Select("")
    Dim ls1 As new List(Of String)
    ls1.AddRange(dr("第二列").split(","))
    Dim ls2 As new List(Of String)
    ls2.AddRange(dr("第三列").split(","))
    If ls1.count > ls2.count Then
        Dim s As String = ls2(ls2.count-1)
        For i As Integer = ls2.count+1 To ls1.count
            ls2.add(s)
        Next
    Else
        Dim s As String = ls1(ls1.count-1)
        For i As Integer = ls1.count+1 To ls2.count
            ls1.add(s)
        Next
    End If
    For i As Integer = 0 To ls1.count-1
        Dim ndr As DataRow = dt2.AddNew
        ndr("第一列") = dr("第一列")
        ndr("第二列") = ls1(i)
        ndr("第三列") = ls2(i)
    Next
Next

 回到顶部