以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 请老师帮我修改“学生成绩统计”代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170270) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:xusuyang -- 发布时间:2021/7/19 22:55:00 -- 请老师帮我修改“学生成绩统计”代码
For Each dr As DataRow In DataTables("学生成绩统计表").DataRows dr("语数英_小计")=dr("语文_分数")+dr("数学_分数")+dr("英语_分数") dr("物化生_小计")=dr("物理_分数")+dr("化学_分数")+dr("生物_分数") dr("语数英物化生_总分数")=dr("语文_分数")+dr("数学_分数")+dr("英语_分数")+dr("物理_分数")+dr("化学_分数")+dr("生物_分数") Next Dim drs As List(of DataRow) =
DataTables("学生成绩统计表").Select("班级 is not null","语数英物化生_总分数") For i As Integer = 0 To
drs.Count - 1 drs(i)("语文_级名") = i + 1 Next For i As Integer = 0 To
drs.Count - 1 drs(i)("数学_级名") = i + 1 Next For i As Integer = 0 To
drs.Count - 1 drs(i)("英语_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("语数英_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("物理_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("化学_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("生物_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("物化生_级名") = i + 1 Next For i As Integer = 0 To drs.Count
- 1 drs(i)("语数英物化生_级名") = i + 1 Next Dim lst As List(of String ) =
DataTables("学生成绩统计表").GetValues("班级","班级 is not
null") For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","语文_分数 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("语文_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","数学_分数 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("数学_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","英语_分数 desc ") For i As
Integer = 0 To drs.Count - 1 drs(i)("英语_班名") = + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","语数英_小计 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("语数英_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","物理_分数 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("物理_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","化学_分数 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("化学_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","生物_分数 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("生物_班名") = i + 1 Next Next For Each s As String In lst drs =
DataTables("学生成绩统计表").Select("班级=\'" & s & "\'","物化生_小计 desc ") For i As
Integer = 0 To drs.Count - 1
drs(i)("物化生_班名") = i + 1 Next Next For Each s As String In lst drs = DataTables("学生成绩统计表").Select("班级=\'" & s
& "\'","语数英物化生_总分数 desc ") For i As
Integer = 0 To drs.Count - 1 drs(i)("语数英物化生_班名") = i + 1 Next Next 上表是共9个同学在不同的3个班的一次考试成绩表。 老师:您好!上述代码不能完全实现以下要求。请老师修改一下。谢谢!!! 用代码来实现每个同学各科_分数,语数英_小计,语数英物化生_总分数的级名不同,如何在“级名”列显示相应的名次“数目” ;班名不同,如何在“班名”列显示相应的名次“数目”? 当“级名”、“班名” 并列是,如何在“级名”列、“班名”列显示相同相应的重复名次的“数目”? 1、 如表所示的成绩,一班的“宗”同学:“语文”的成绩150级名为第一名,如何在“级名”列显示为“1”? 班名为第一名,如何在“班名”列显示为“1”?“数学”成绩与三班“张”同学“数学”成绩均是148级名并列第二名,如何在“级名”列显示为“2”?“张”同学“数学”成绩 班名排第一名,如何在“班名”列显示为“1”? 即各科_分数、语数英_小计、语数英物化生_总分数的级名是随各科分数变化而变化,而不应该是用某一科成绩的级名作为所有学科成绩的年级排名? 3、三班的“安”同学语文成绩与二班的“杨”同学语文成绩145是级名并列第3名,如何在“级名” 列与二班的“杨”同学均显示为“3”? 一班的“孔”同学与同班的“需”同学语文成绩均146,是级名并列第二名,如何在“孔”同学的“级名”列、“孔”同学的“级名”列均显示为“2”? “孔”同学与同班的“需”同学语文成绩还是班名并列第二名,如何在“孔”同学“班名”列显示为“2”, 在“需”同学“班名”列也显示为“2”,? 4、当某一科成绩清除时,班名列、级名列如何显示为清空状态? 我的版本2021.4.5前版本 谢谢!!! |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2021/7/19 23:06:00 -- 级名的用法改为和班名一样的逻辑啊! Dim drs As List(of DataRow) = DataTables("学生成绩统计表").Select("班级 is not null","语文_分数 desc") For i As Integer = 0 To drs.Count - 1 drs(i)("语文_级名") = i + 1 Next drs = DataTables("学生成绩统计表").Select("班级 is not null","数学_分数 desc") For i As Integer = 0 To drs.Count - 1 drs(i)("数学_级名") = i + 1 Next |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2021/7/19 23:10:00 -- 如果同分同排名,请认真看看帮助:http://www.foxtable.com/webhelp/topics/2382.htm Dim drs As List(of DataRow) = DataTables("学生成绩统计表").Select("班级 is not null","语文_分数 desc") For n As Integer = 0 To drs.Count - 1 If n > 0 AndAlso drs(n)("语文_分数") = drs(n-1)("语文_分数") Then \'如果总分和上一行相同 drs(n)("语文_级名") = drs(n-1)("语文_级名") \'则排名等于上一行 Else drs(n)("语文_级名") = n + 1 \'设置排名 End If Next drs = DataTables("学生成绩统计表").Select("班级 is not null","数学_分数 desc") For n As Integer = 0 To drs.Count - 1 If n > 0 AndAlso drs(n)("数学_分数") = drs(n-1)("数学_分数") Then \'如果总分和上一行相同 drs(n)("数学_级名") = drs(n-1)("数学_级名") \'则排名等于上一行 Else drs(n)("数学_级名") = n + 1 \'设置排名 End If Next |