以下是引用狐狸爸爸在2008-11-12 8:22:00的发言:呵呵,我怎么测试才一秒左右啊。
用下面的代码应该好一点。
还有要注意不是所有的列都应该设置成双精度型,排名、班级、学号这样的列应该是整数型。
e.Form.Controls("Label1").text="请稍等,正在计时..."
dim timestart,timeend as date
timestart=date.now
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
CurrentTable.Filter= "[班级] = '" & pm(i) & "'"
Currenttable.sort = ColName & " DESC"
pmc = 0
TotalName = ColName & "班级排名"
For n As integer = 0 to Currenttable.rows.Count -1
pmc = pmc +1
If n > 0 AndAlso Currenttable.rows(n)(TotalName ) = Currenttable.rows(n-1)(TotalName ) Then
CurrentTable.Rows(n)(TotalName ) = CurrentTable.Rows(n-1)(TotalName )
Else
CurrentTable.Rows(n)(TotalName ) = pmc
End If
Next
Next
Next
Tables("学生各科成绩表").Sort = "总分 DESC" '排序,对总分列以降序排序
CurrentTable.Filter = "" '取消筛选
CurrentTable.Redraw = True '刷新表
timeend=date.now
e.Form.Controls("Label1").text="耗时" & (timeend-timestart).TotalSeconds & "秒"
Messagebox.Show("统计完毕!")
[此贴子已经被作者于2008-11-12 8:25:52编辑过]