Foxtable(狐表)用户栏目专家坐堂 → 自动分组问题


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

主题:自动分组问题

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/11 9:11:00 [显示全部帖子]

Dim dt1 As DataTable = DataTables("分组计划")
Dim dt2 As DataTable = DataTables("原始数据")
Dim cs() = {"一", "二", "三", "四", "五", "六"}
For Each r As DataRow In dt1.Select("")
    For Each c As String In cs
        If val(r("分组" & c)) > 0 Then
            Dim drs = dt2.Select("课程" & c & " = '" & r("科目") & "'")
            Dim rs As Integer = Math.Ceiling(drs.count/r("分组" & c))
            For i As Integer = 1 To r("分组" & c)
                For j As Integer = rs*(i-1) To rs*i
                    If j < drs.count Then
                        drs(j)("分组" & c) = i
                    End If
                Next
            Next
        End If
    Next
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/12 8:46:00 [显示全部帖子]

Dim dt1 As DataTable = DataTables("分组计划")
Dim dt2 As DataTable = DataTables("原始数据")
Dim cs() = {"一", "二", "三", "四", "五", "六"}
For Each r As DataRow In dt1.Select("")
    Dim idx As Integer = 0
    For Each c As String In cs
        If val(r("分组" & c)) > 0 Then
            Dim drs = dt2.Select("课程" & c & " = '" & r("科目") & "'")
            Dim rs As Integer = Math.Ceiling(drs.count/r("分组" & c))
            For i As Integer = 1 To r("分组" & c)
                idx += 1
                For j As Integer = rs*(i-1) To rs*i
                    If j < drs.count Then
                        drs(j)("分组" & c) = idx
                    End If
                Next
            Next
        End If
    Next
Next

 回到顶部