e.Form.Controls("Label1").text="排名中,请稍候..."
Dim Time,Time1 As Date
Time = Date.now
Application.Doevents
DataTables("成绩排名").DataRows.Clear()
Dim f As New Filler
f.SourceTable = DataTables("成绩表")
f.DataTable = DataTables("成绩排名")
f.ExcludeExistValue = True
f.Filter = "期数 is not null"
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("Label1").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
http://www.foxtable.com/bbs/dispbbs.asp?boardid=5&Id=1685&page=6