应该加上捕获异常错误代码,否则会报错的。
If e.DataCol.Name = "数字" Then
try
If e.DataRow("数字") Like "########"
e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yyyyMMdd",Nothing)
Else If e.DataRow("数字") Like "######"
e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yyMMdd",Nothing)
Else If e.DataRow("数字") Like "##[-]##[-]##"
e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yy-MM-dd",Nothing)
Else If e.DataRow("数字") Like "##[-]##"
e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"MM-dd",Nothing)
Else If e.DataRow("数字") Like "####"
e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"MMdd",Nothing)
Else
Return
End If
Catch ex As Exception
End try
End If