For Each key As String In dic1.keys
Dim dr2 As DataRow = DataTables("教师课时奖励").AddNew()
Dim str() As String = key.Split("|")
dr2("教师姓名") = str(0)
dr2("学科")=str(1)
dr2("学期")=str(2)
dr2("超班额金额") = dic2(key)
Next
改为:
For Each key As String In dic1.keys
Dim dr2 As DataRow = DataTables("教师课时奖励").AddNew()
Dim str() As String = key.Split("|")
if str.Length >=3 then
dr2("教师姓名") = str(0)
dr2("学科")=str(1)
dr2("学期")=str(2)
dr2("超班额金额") = dic2(key)
end if
Next