Dim fls As List(Of String()) = DataTables("成绩管理").GetValues("期数|年级|班级") For Each fl As String() In fls Dim filter As String = "期数 = '" & fl(0) & "' and 年级 = '" & fl(1) & "' and 班级 = '" & fl(2) & "'" Dim ColNames() As String = {"语文_成绩","数学_成绩","外语_成绩","科学_成绩","历社_成绩","总分_成绩"} For Each ColName As String In ColNames Dim TotalName As String = ColName.SubString(0,2) & "_排名" Dim drs As List(Of DataRow) = DataTables("成绩管理").Select(filter, colname & " DESC") For n As Integer = 0 To drs.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 ) = n + 1 '设置排名 End If Next Next Next