Tables("成绩库").Sort = "姓名"
For Each Value As String In Values
For Each xuanke As String In xuankes
For Each danwei As String In DataTables("成绩库").GetValues("单位", " ")
For Each nianji As String In DataTables("成绩库").GetValues("年级","单位 = '" & danwei & "'" )
For Each zuhe As String In DataTables("成绩库").GetValues("组合","年级 = '" & nianji & "'" )
Dim tj As String = value & "排序"
'Dim tj5 As String = "序号"
Dim drs As List(Of DataRow) = DataTables("成绩库").Select("[年级] = '" & nianji & "'And [单位] = '" & danwei & "'", "" & value & "")
Dim idx As Integer = 1
For n As Integer = 0 To drs.Count - 1 Step 40 '遍历所有行
Dim idx2 As Integer = 1
For k As Integer = n To math.min(n+39,drs.Count - 1)
drs(k)(tj) = k + 1 '设置排序
drs(k)("考场号") = idx
drs(k)("座位号") = idx2
idx2 += 1
Next
If n+44 >= drs.Count - 1 Then
For k As Integer = n+40 To drs.Count - 1
drs(k)(tj) = k + 1 '设置排序
drs(k)("考场号") = idx
drs(k)("座位号") = idx2
idx2 += 1
Next
exit for
End If
idx + =1
Next
Dim tj1 As String = xuanke & "排序"
Dim tj2 As String = xuanke & "考场号"
Dim tj3 As String = xuanke & "座位号"
……