Select Case e.DataCol.Name Case "批号" if e.newValue <> Nothing AndAlso e.newvalue.Length >= 8 then Dim s As String = CStr(e.NewValue) Dim d As Date =new Date(s.SubString(0,4),s.SubString(4,2),s.SubString(6,2)) d = d.AddYears(1).AddDays(-1) e.DataRow("有效期") = Format(d,"yyyyMMdd") end if End Select