以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 思路分析 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=168887) |
||
-- 作者:13796361423 -- 发布时间:2021/5/26 9:23:00 -- 思路分析 我想把 表学生名册 里 1班的学生 按照 成绩 前6名的学生 提出来 到表2, 1班剩下的学生放到表3; 2班的学生 按照 成绩 前14名的学生 提出来 到表2, 2班剩下的学生放到表3. 请问如何实现能方便? 就是一个表分成两个表,按照成绩分出来。 就是每班分出的人数不定。
|
||
-- 作者:有点蓝 -- 发布时间:2021/5/26 9:47:00 -- 比如 dim cj as double dim drs as list(of datarow) = DataTables("表A").Select("","成绩 desc") For i as integer = 0 to drs.count - 1 dim dr1 as datarow = drs(i) if i < 6\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol in DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol in DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next end if Next |
||
-- 作者:13796361423 -- 发布时间:2021/5/26 11:51:00 -- 请问加个条件 Dim cj As Double Dim drs As List(of DataRow) = DataTables("表A").Select("","成绩 desc") For i As Integer = 0 To drs.count - 1 Dim dr1 As DataRow = drs(i) If i < 6\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next Else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next End If Next 这个代码挺好使, 我想问一下, 我再加个条件, 如果“第一中学”的前6分出来, “第一中学”那个条件加在哪里啊。 然后是“第二中学”“第三中学”“第四中学” 都按照固定的数分出来。 谢谢。
|
||
-- 作者:有点蓝 -- 发布时间:2021/5/26 11:56:00 -- Dim drs As List(of DataRow) = DataTables("表A").Select("学校=\'第一中学\'","成绩 desc") |
||
-- 作者:13796361423 -- 发布时间:2021/5/26 12:19:00 -- 请问如何其它学校筛选出来 Dim cj As Double Dim drs As List(of DataRow) = DataTables("表A").Select("学校=\'第一中学\'","成绩 desc") For i As Integer = 0 To drs.count - 1 Dim dr1 As DataRow = drs(i) If i < 2\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next Else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next End If Next Dim cj As Double Dim drs As List(of DataRow) = DataTables("表A").Select("学校=\'第二中学\'","成绩 desc") For i As Integer = 0 To drs.count - 1 Dim dr1 As DataRow = drs(i) If i < 3\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next Else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next End If Next Dim cj As Double Dim drs As List(of DataRow) = DataTables("表A").Select("学校=\'第三中学\'","成绩 desc") For i As Integer = 0 To drs.count - 1 Dim dr1 As DataRow = drs(i) If i < 2\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next Else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next End If Next 请问如何把他们合并到一起? |
||
-- 作者:有点蓝 -- 发布时间:2021/5/26 13:58:00 -- dim str() as string = {“第一中学”,“第二中学”,“第三中学”,“第四中学”} for each s as string in str Dim drs As List(of DataRow) = DataTables("表A").Select("学校=\'“ & s & ”\'","成绩 desc") For i As Integer = 0 To drs.count - 1 Dim dr1 As DataRow = drs(i) If i < 2\'前6名 Dim dr2 As DataRow = DataTables("表B").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next Else Dim dr2 As DataRow = DataTables("表C").AddNew() For Each dc As DataCol In DataTables("表A").DataCols dr2(dc.Name) = dr1(dc.name) Next End If Next next
|
||
-- 作者:13796361423 -- 发布时间:2021/5/26 14:02:00 -- 每个学校取的学生不一样 你好, 我这个每个学校取的学生不一样, 比如 一中 2名 , 二中 3名 , 三中 4名 , 如何设置啊 |
||
-- 作者:有点蓝 -- 发布时间:2021/5/26 14:07:00 --
|