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
这是学生成绩的年级排名代码
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
这是学生成绩的班级排名代码,这两段代码,如何合并到一起,用一个窗口按钮公式完成,谢谢老师!