Dim com4 As String = e.Form.Controls("combobox4").text
If com4 > ""
Dim Cols1() As String = {"学校名称","年级","班级","学生姓名","学生ID","学校标识码"}
Dim Cols2() As String = {"单位名称","年级代码","班级","姓名","学生ID","学校代码"}
Dim su As Integer = 0
Dim dr2 As DataRow
For Each dr1 As DataRow In DataTables("学生信息").DataRows
dr2 = DataTables("成绩").sqlFind("学生ID = '" & dr1("学生ID") & "' and 考试名称 = '" & com4 & "'")
If dr2 Is Nothing Then dr2 = DataTables("成绩").AddNew()
For i As Integer = 0 To Cols1.Length -1
Select Case i
Case 0
dr2(Cols2(i)) = dr1(Cols1(i))
Case 1
dr2(Cols2(i)) = dr1(Cols1(i)).Substring(4,2)
Case 2
Dim c() As Char = {"级", "班"}
Dim str As String = dr1(Cols1(i))
Dim s1() As String = str.Split(c)
dr2(Cols2(i)) = s1(1).PadLeft(2,"0")
Case 3
dr2(Cols2(i)) = dr1(Cols1(i))
Case 4
dr2(Cols2(i)) = dr1(Cols1(i))
Case 5
dr2(Cols2(i)) = trim(dr1(Cols1(i))).Substring(6,4)
End Select
Next
dr2("考试名称") = com4
su = su +1
dr2.Save
Next
Dim sux As String = "本次共导入学生" & su & "人"
MessageBox.show(sux,"导入总计",MessageBoxButtons.OK)