If e.Form.Controls("年级1").value Is Nothing Then
MessageBox.Show("请选择或输入统计年级后再执行此操作","中止操作",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Return
End If
Dim dt As Table = Tables("成绩库")
Dim Kms() As String = {"考号重排"}
Dim xks() As String = {"化学","生物","政治","地理"}
Dim djs() As String = {"化","生","政","地"}
Dim liem1s() As String = {"单位","单位代码","部别","组合","组合代码","姓名","备注"}
Dim liem2s() As String = {"年级","班","期","编号","考号","班级名称","班级代码"}
Dim liem3s() As String = {"排序","座位号","序号"}
Dim liem4s() As String = {"考场号"}
Dim tjnj As String = e.Form.Controls("年级1").text
For Each xk As String In xks
Dim dtb As New DataTableBuilder( tjnj &"级"& xk &"考号名册")
For Each liem1 As String In liem1s
dtb.AddDef(""& liem1 &"",Gettype(String),8)
Next
For Each liem2 As String In liem2s
dtb.AddDef(""& liem2 &"",Gettype(Double))
Next
For j As Integer = 0 To djs.length - 1
dtb.AddDef(""& djs(j) &"",Gettype(String),"","科目")
Next
For Each liem3 As String In liem3s
For j As Integer = 0 To djs.length - 1
dtb.AddDef(djs(j) & liem3 ,Gettype(Double),"",liem3)
Next
Next
For Each liem4 As String In liem4s
For j As Integer = 0 To djs.length - 1
dtb.AddDef(djs(j) & liem4 ,Gettype(String),"",liem4)
Next
Next
dtb.Build()
Next
For j As Integer = 0 To djs.length - 1
DataTables( tjnj &"级"& xks(j) &"考号名册").DataRows.Clear()
Dim f As New Filler
f.SourceTable = DataTables("成绩库")
f.DataTable = DataTables( tjnj &"级"& xks(j) &"考号名册")
f.Filter = "([组合] Like '%" & djs(j) & "%') And 年级 = '" & tjnj & "'"
f.Fill()
For Each xk As String In xks
Tables( tjnj &"级"& xk &"考号名册").SetHeaderRowHeight(60) '表标题行的行高
Tables( tjnj &"级"& xk &"考号名册").DefaultRowHeight = 24 '设置默认的行高
For Each liem1 As String In liem1s
For Each liem2 As String In liem2s
For Each liem4 As String In liem4s
For Each dj As String In djs
Dim lms() As String = {liem1,liem2,dj & liem4,dj}
For Each lm As String In lms
Tables( tjnj &"级"& xk &"考号名册").Cols(""& lm &"").TextAlign = TextAlignEnum.Center
Next
Next
Next
Next
Next
If xk = "化学" Then
Tables( tjnj &"级"& xk &"考号名册").SetColVisibleWidth("单位|60|单位代码|35|部别|50|年级|35|组合|50|组合代码|35|班|26|期|26|编号|80|姓名|60|考号|80|化|45|化排序|40|化考场号|70|化座位号|45|化序号|45|班级名称|55|班级代码|55")
Tables( tjnj &"级"& xk &"考号名册").Sort = "单位代码,化考场号,化座位号,化序号"
ElseIf xk = "生物" Then
Tables( tjnj &"级"& xk &"考号名册").SetColVisibleWidth("单位|60|单位代码|35|部别|50|年级|35|组合|50|组合代码|35|班|26|期|26|编号|80|姓名|60|考号|80|生|45|生排序|40|生考场号|70|生座位号|45|生序号|45|班级名称|55|班级代码|55")
Tables( tjnj &"级"& xk &"考号名册").Sort = "单位代码,生考场号,生座位号,生序号"
ElseIf xk = "政治" Then
Tables( tjnj &"级"& xk &"考号名册").SetColVisibleWidth("单位|60|单位代码|35|部别|50|年级|35|组合|50|组合代码|35|班|26|期|26|编号|80|姓名|60|考号|80|政|45|政排序|40|政考场号|70|政座位号|45|政序号|45|班级名称|55|班级代码|55")
Tables( tjnj &"级"& xk &"考号名册").Sort = "单位代码,政考场号,政座位号,政序号"
ElseIf xk = "地理" Then
Tables( tjnj &"级"& xk &"考号名册").SetColVisibleWidth("单位|60|单位代码|35|部别|50|年级|35|组合|50|组合代码|35|班|26|期|26|编号|80|姓名|60|考号|80|地|45|地排序|40|地考场号|70|地座位号|45|地序号|45|班级名称|55|班级代码|55")
Tables( tjnj &"级"& xk &"考号名册").Sort = "单位代码,地考场号,地座位号,地序号"
Else
End If
Next
Next
上面红色部分代码能否简化?
For Each dj As String In djs
Tables( tjnj &"级"& xk &"考号名册").SetColVisibleWidth("单位|60|单位代码|35|部别|50|年级|35|组合|50|组合代码|35|班|26|期|26|编号|80|姓名|60|考号|80|"& dj &"|45|" & dj & "排序|40|" & dj & "考场号|70|" & dj & "座位号|45|" & dj & "序号|45|班级名称|55|班级代码|55")
Tables( tjnj &"级"& xk &"考号名册").Sort = "单位代码," & dj & "考场号," & dj & "座位号," & dj & "序号"
Next
代码如何修改?请指教。谢谢!