Dim d1 As Date = e.Form.Controls("DateTimePicker1").Value Dim d2 As Date = e.Form.Controls("DateTimePicker2").Value If d1 = Nothing Or d2 = Nothing Then e.Form.Controls("Label6").Text = "" Else e.Form.Controls("Label6").Text = DateDiff("yyyy",d2,d1) End If