以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 代码错在哪里? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130352) |
-- 作者:ybmjy -- 发布时间:2019/1/19 19:06:00 -- 代码错在哪里? 为什么下面的代码只能复制一条选中行的数据 With Tables("员工工资表") Dim n As Integer = .BottomPosition -.TopPosition Dim m As Integer = n+1 Dim dr As Row = Tables("考勤表").AddNew(m) For i As Integer = .TopPosition To .BottomPosition dr("姓名") = Tables("员工工资表").Rows(i)("姓名") Next End With |
-- 作者:ybmjy -- 发布时间:2019/1/19 20:23:00 -- 搞定 Dim str As String = "" For i As Integer = Tables("员工工资表").TopPosition To Tables("员工工资表").BottomPosition str = str & "," & Tables("员工工资表").Rows(i)("_Identify") Next Dim f As New Filler f.SourceTable = DataTables("员工工资表") \'指定数据来源 f.SourceCols = "姓名,工天" \'指定数据来源列 f.DataTable = DataTables("考勤表") \'指定数据接收表 f.DataCols = "姓名,合计" \'指定数据接收列 f.Filter = "[_Identify] in (" & str.Trim(",") & ")" f.Fill() \'填充数据 |
-- 作者:ybmjy -- 发布时间:2019/1/20 22:38:00 -- 还是这样好点 Dim str As String = "" Dim Filter As String For i As Integer = Tables("员工工资表").TopPosition To Tables("员工工资表").BottomPosition str = str & "," & Tables("员工工资表").Rows(i)("_Identify") Next Dim Cols1() As String = {"姓名","工天"} Dim Cols2() As String = {"姓名","合计"} filter = "_Identify in (" & str.Trim(",") & ")" For Each dr1 As DataRow In DataTables("员工工资表").Select(Filter) Dim dr2 As DataRow = DataTables("考勤表").AddNew For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next Next |