If e.DataCol.Name = "批号" Then Dim dr As DataRow = e.DataRow If dr.IsNull("批号") Then dr("生产日期") = Nothing dr("到期日") = Nothing Else Dim s As String= "20" & dr("批号") s= Mid(s,1,4) & "-" & Mid(s,5,2) & "-" & Mid(s,7,2) dr("生产日期") = Cdate(s) dr("到期日") = dr("生产日期").adddays(7) End If End If