你要判断字符的长度才行,比如
If e.DataCol.name = "班级全称"
Dim c() As Char = {"级", "班"}
Dim str As String = e.DataRow("班级全称")
Dim s1() As String = str.Split(c)
If s1.length >= 2 AndAlso s1(0).length >= 6 Then
e.DataRow("班级") = s1(1).PadLeft(2,"0")
e.DataRow("年级代码") = str(val(s1(0).Substring(4,2))+3)
End If
End If