Foxtable(狐表)用户栏目专家坐堂 → 成绩单元格为空时计算出错


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

主题:成绩单元格为空时计算出错

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


加好友 发短信
等级:一尾狐 帖子:401 积分:3639 威望:0 精华:0 注册:2016/11/12 18:42:00
成绩单元格为空时计算出错  发帖心情 Post By:2021/5/8 14:28:00 [显示全部帖子]

成绩单元格为空时计算出错,必须输入数据或输入0,如何个别学生不输入也能计算其他人的成绩

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


加好友 发短信
等级:一尾狐 帖子:401 积分:3639 威望:0 精华:0 注册:2016/11/12 18:42:00
  发帖心情 Post By:2021/5/8 14:48:00 [显示全部帖子]

e.Form.Controls("Label1").text="排名中,请稍候..."
Dim Time,Time1 As Date
Time = Date.now
Application.Doevents
DataTables("成绩排名").DataRows.Clear()
Dim f As New Filler
f.SourceTable = DataTables("学生成绩")
f.SourceCols = "名称,年级,班级,姓名,语文,数学,英语,物理,化学,政治,历史,地理,生物"
f.DataTable = DataTables("成绩排名")
f.DataCols = "名称,年级,班级,姓名,语文,数学,英语,物理,化学,政治,历史,地理,生物"
f.ExcludeExistValue = True
f.ExcludeNullValue = True
f.Fill

Dim pm As List(Of String()) = CurrentTable.DataTable.GetUniqueValues("","名称","年级","班级")
Dim pmc As Integer
Dim ColNames() As String = {"语文","数学","英语","化学","物理","政治","历史","地理","生物","总分"}
Dim TotalName As String
CurrentTable.Redraw = False
For Each ColName As String In ColNames
    For i As Integer = 0 To pm.Count -1
        If pm(i)(0) = "" Then
            Continue For
        End If
        Dim drs As List(Of DataRow) = CurrentTable.DataTable.Select("[名称] = '" & pm(i)(0) & "'And [年级] = '" & pm(i)(1) & "'And [班级] = " & pm(i)(2), ColName & " DESC")
        
        pmc = 0
        TotalName = ColName & "排名"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = pmc
            End If
        Next
    Next
Next

CurrentTable.Redraw = True
Tables("成绩排名").Sort = "名称,年级,班级,总分排名"
Time1 = Date.Now
e.Form.Controls("Label1").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
Messagebox.Show("按班级内排名完成!请查看!")
[此贴子已经被作者于2021/5/8 14:50:03编辑过]

 回到顶部