各位老师,有个疑问,比如成绩表中物理没有考试,即没有分数,下列代码生成排名时,还是有排名(全部都是1)
如果物理、化学没有考试,能不能不生成排名(即排名列为空)呢?
此主题相关图片如下:1234.jpg
源代码如下:
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