以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]如何实现年级排名与班级排名公式 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143528) |
||||
-- 作者:hbfnmxb -- 发布时间:2019/11/27 17:34:00 -- [求助]如何实现年级排名与班级排名公式 学生成绩汇总表中有某某学科班级排名和某某学科年级,如:语文年级排名、语文班级排名、数学年级排名、数学班级排名等,下面这段:Tables("学生成绩汇总表").StopRedraw Dim bjs As List(Of String) = DataTables("学生成绩汇总表").GetValues("班级","[班级] Is Not NULL") Dim Count As Integer Dim ColNames() As String = {"语文","数学","英语","化学","物理","总分"} Dim TotalName As String For Each ColName As String In ColNames \' For i As Integer = 0 To bjs.Count -1 Dim drs As List(Of DataRow) = DataTables("学生成绩汇总表").Select("[班级] = " & bjs(i), ColName & " DESC") Count = 0 TotalName = ColName & "排名" For n As Integer = 0 To drs.Count - 1 Count = Count + 1 If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then drs(n)(TotalName ) = drs(n-1)(TotalName ) Else drs(n)(TotalName ) = Count End If Next Next Next Tables("学生成绩汇总表").Sort = "总分 DESC" Tables("学生成绩汇总表").ResumeRedraw 如何实现学科的年级排名和学科的班级排名。谢谢老师!!
[此贴子已经被作者于2019/11/27 18:22:51编辑过]
|
||||
-- 作者:hbfnmxb -- 发布时间:2019/11/27 18:50:00 -- 自己顶一下 |
||||
-- 作者:有点蓝 -- 发布时间:2019/11/27 20:33:00 -- 添加对应的语文年级排名、语文班级排名等等列,然后代码条件改为年级不就行了 Tables("学生成绩汇总表").StopRedraw
Dim bjs As List(Of String) = DataTables("学生成绩汇总表").GetValues("年级","[年级] Is Not NULL") Dim Count As Integer Dim ColNames() As String = {"语文","数学","英语","化学","物理","总分"} Dim TotalName As String For Each ColName As String In ColNames \' For i As Integer = 0 To bjs.Count -1 Dim drs As List(Of DataRow) = DataTables("学生成绩汇总表").Select("[年级] = " & bjs(i), ColName & " DESC") Count = 0 TotalName = ColName & "年级排名" For n As Integer = 0 To drs.Count - 1 Count = Count + 1 If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then drs(n)(TotalName ) = drs(n-1)(TotalName ) Else drs(n)(TotalName ) = Count End If Next Next Next Tables("学生成绩汇总表").Sort = "总分 DESC" Tables("学生成绩汇总表").ResumeRedraw |
||||
-- 作者:有点蓝 -- 发布时间:2019/11/27 20:34:00 -- 如果要班级年级同时排名,先调用1楼的代码,再调用3楼的代码即可 |
||||
-- 作者:hbfnmxb -- 发布时间:2019/11/28 7:46:00 -- 老师,您给看一下这个附件:总是出现问题,按您说得,没有找到问题的原因。不知道问题出在哪里?
|
||||
-- 作者:有点蓝 -- 发布时间:2019/11/28 9:24:00 -- Tables("学生成绩汇总表").StopRedraw Dim bjs As List(Of String) = DataTables("学生成绩汇总表").GetValues("年级","[年级] Is Not NULL") Dim Count As Integer Dim ColNames() As String = {"语文","数学","英语","化学","物理","政治","历史","地理","生物","总分"} Dim TotalName As String For Each ColName As String In ColNames \' For i As Integer = 0 To bjs.Count -1 Dim drs As List(Of DataRow) = DataTables("学生成绩汇总表").Select("[年级] = \'" & bjs(i) & "\'", ColName & " DESC") Count = 0 TotalName = ColName & "年级排名" For n As Integer = 0 To drs.Count - 1 Count = Count + 1 If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then drs(n)(TotalName ) = drs(n-1)(TotalName ) Else drs(n)(TotalName ) = Count End If Next Next Next Tables("学生成绩汇总表").Sort = "总分 DESC" Tables("学生成绩汇总表").ResumeRedraw
|
||||
-- 作者:hbfnmxb -- 发布时间:2019/11/28 9:36:00 -- 老师讲下,这里,想弄明白怎么回事!!谢谢老师! Dim drs As List(Of DataRow) = DataTables("学生成绩汇总表").Select("[年级] = \'" & bjs(i) & "\'", ColName & " DESC")
|
||||
-- 作者:有点蓝 -- 发布时间:2019/11/28 9:42:00 -- 表达式的字符串需要使用单引号引起来:http://www.foxtable.com/webhelp/topics/1284.htm |
||||
-- 作者:hbfnmxb -- 发布时间:2019/11/28 9:55:00 -- 谢谢老师!还有一个问题:学生成绩汇总表中的学科主观成绩,如语文主观、数学主观等,还有学科客观成绩 ,如语文客观、数学客观等,想引用主观题表中的成绩和客观题表中的成绩,主观题表中的成绩按学号,如何引用到学生成绩汇总表中,客观题的成绩如何按学号引用到学生成绩汇总表! |
||||
-- 作者:有点蓝 -- 发布时间:2019/11/28 10:18:00 -- 参考:http://www.foxtable.com/webhelp/topics/1451.htm |