请教
这是成绩表按班级排序代码,
Dim bjs As List(Of String) = DataTables("成绩表").GetUniqueValues("[班级] 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"如果不按班级排序,而是按性别排序,公式该如何修改,谢谢!
[此贴子已经被作者于2009-1-8 23:17:17编辑过]
没什么两样,只需将上述代码中的所有“班级”改“性别”。
另外性别的列属性应该是字符型,所以下面这段代码需更改
Dim drs As List(Of DataRow) = DataTables("成绩表").Select("[班级] = " & bjs(i), ColName & " DESC")
更正后即:
Dim drs As List(Of DataRow) = DataTables("成绩表").Select("[性别] = '" & bjs(i) & "'" , ColName & " DESC") 这样应该没有问题了。
谢谢C版主!原来是这个'" & bjs(i) & "'" 问题