Select Case e.DataCol.name Case "开始日期","结束日期" If e.DataRow.IsNull("开始日期") OrElse e.DataRow.IsNull("结束日期") Then e.DataRow("天数") = Nothing Else Dim y,m,d As Integer Dim dt1 As Date = e.DataRow("开始日期") Dim dt2 As Date = e.DataRow("结束日期") DateYMD(dt1,dt2,y,m,d) dt1 = dt1.AddYears(y) d= (dt2- dt1).TotalDays() e.DataRow("天数") = y & "年" & d & "天" End If End Select