第一组代码
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"
第二组代码
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"
文件如下图所示
此主题相关图片如下:01.jpg
在这样的文件中运行第一组代码,能正确排序,按班级排
我想要按学校排序,就将第一组代码换成第二组代码,运行时出错,(如下图所示)
此主题相关图片如下:02.jpg
不知道何原因,如果要按学校排,第二组代码应该怎么修改呢?请朋友们帮看看,谢谢。
[此贴子已经被作者于2011-10-19 20:07:07编辑过]