If e.DataCol.Name = "SmsBody" Then '如果更改的是身份证号码列
If e.DataRow.IsNull("SmsBody") Then '身份证号码是否为空
e.DataRow("会议时间") = Nothing '如果为空,则清除出生日期
Else
Dim str As String = e.DataRow("SmsBody")
Dim part As String = "\d{4}年\d{1,2}月\d{1,2}日"
Dim mc As object = System.Text.RegularExpressions.Regex.Matches(str, "\d{4}年\d{1,2}月\d{1,2}日")
If mc.IsMatch(part,str) = True Then 此处加个判断看匹配成功不,用法有错,如下楼请修改
Dim rq As String = mc(0).value
rq = rq.Replace("年","-").replace("月","-").replace("日","-").Trim("-")
Dim rq2 As Date
If Date.TryParse(rq, rq2) Then '如果转换成功 黄色部分已照帮助修改,但仍报错,错不在此处。
e.DataRow("会议时间") = rq2 ' Output.Show(d) '输出转换结果
Else
e.DataRow("会议时间") = Nothing 'Output.Show("无效日期格式") '给出错误提示
End If
End If
End If
End If