以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  共享:连续填充问题(Czy老师)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=5440)

--  作者:abcdzabcdz
--  发布时间:2009/12/11 12:28:00
--  共享:连续填充问题(Czy老师)

问题:连续填充
    详细说明:根据“参数表”中的相关参数,将“课程表”中相应列重复填充到“过渡表”中?若将星期一至六的数据分别为“434204,则将“课程表”中星期一的数据连续填充4次到过渡表的“星期一”部分,将“课程表“中星期二的数据连续3次填充到过渡表的“星期二”部分,……….,将“课程表”中星期六数据连续4次填充到过渡表的“星期六”部分。

 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:1234555.table

[此贴子已经被作者于2009-12-12 1:41:59编辑过]

--  作者:abcdzabcdz
--  发布时间:2009/12/11 12:29:00
--  
问题CZY老师早也解决,不敢独享,故为C版占位:

DataTables("过渡表").DataRows.Clear()
Tables("过渡表").Redraw = False
Dim dt As Table = Tables("过渡表")
Dim Count As Integer = Tables("课程表").Count
Dim dr As DataRow
Dim ColNames() As String = {"星期一","星期二","星期三","星期四","星期五","星期六"}
Dim Max As Integer = DataTables("参数表").Compute("Max(重复填充次数)")
For i As integer = 0 to Max -1 \'不管三七二十一,所有数据全部重复向过渡表写入最大值次数
    For Each dr1 As DataRow In DataTables("课程表").DataRows
        Dim dr2 As DataRow = DataTables("过渡表").AddNew()
        For Each dc As DataCol In DataTables("过渡表").DataCols
            dr2(dc.name) = dr1(dc.name)
        Next
    Next
Next
For Each ColName As string In ColNames \'折腾一下吧,删除多余的数据
    dr = DataTables("参数表").Find("星期 = \'" & ColName & "\'")
    For c As integer = 0 to 9
        For i As integer = dr("重复填充次数")*Count to dt.rows.count -1
            dt.Rows(i)(ColName & "_" & c+1) = nothing
        Next
    Next
Next
Tables("过渡表").Redraw = True
[此贴子已经被作者于2009-12-12 1:48:12编辑过]

--  作者:czy
--  发布时间:2009/12/11 16:20:00
--  
我来蛮干一下。

DataTables("过渡表").DataRows.Clear()
Tables("过渡表").Redraw = False
Dim dt As Table = Tables("过渡表")
Dim Count As Integer = Tables("课程表").Count
Dim dr As DataRow
Dim ColNames() As String = {"星期一","星期二","星期三","星期四","星期五","星期六"}
Dim Max As Integer = DataTables("参数表").Compute("Max(重复填充次数)")
For i As integer = 0 to Max -1 \'不管三七二十一,所有数据全部重复向过渡表写入最大值次数
    For Each dr1 As DataRow In DataTables("课程表").DataRows
        Dim dr2 As DataRow = DataTables("过渡表").AddNew()
        For Each dc As DataCol In DataTables("过渡表").DataCols
            dr2(dc.name) = dr1(dc.name)
        Next
    Next
Next
For Each ColName As string In ColNames \'折腾一下吧,删除多余的数据
    dr = DataTables("参数表").Find("星期 = \'" & ColName & "\'")
    For c As integer = 0 to 9
        For i As integer = dr("重复填充次数")*Count to dt.rows.count -1
            dt.Rows(i)(ColName & "_" & c+1) = nothing
        Next
    Next
Next
Tables("过渡表").Redraw = True