各学科年级排名公式:
e.Form.Controls("Label3").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) = "" Then
Continue For
End If
Dim drs As List(Of DataRow) = CurrentTable.datatable.Select("[期数] = " & pm(i), 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
Tables("成绩排名").Sort = "总分 DESC"
CurrentTable.Redraw = True
Time1 = Date.Now
e.Form.Controls("Label3").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
下面是各学科班级排名公式:
e.Form.Controls("Label3").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), 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("Label3").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
这两个公式能不能合二为一?(做成一个按钮,即有年级排名,又有班级排名)