```
Public Function CalculateAge(ByVal BirthDate As Object) As String
'returns a string that show years, months and days
Dim intYear As Integer, intMonth As Integer, intDay As Integer
Dim dtTemp As Date
If Not IsDate(BirthDate) Then Exit Function
dtTemp = CDate(BirthDate)
If dtTemp > Now Then Exit Function
intYear = dtTemp.Year
intMonth = dtTemp.Month
intDay = dtTemp.Day
intYear = Date.Now.Year - intYear
intMonth = Date.Now.Month - intMonth
intDay = Date.Now.Day - intDay
If intDay < 0 Then
Select Case dtTemp.Month
Case 1, 3, 5, 7, 8, 10, 12
intDay = 31 - Math.Abs(intDay)
Case 4, 6, 9, 11
intDay = 30 - Math.Abs(intDay)
Case 2
If dtTemp.Year Mod 4 = 0 Then
intDay = 29 - Math.Abs(intDay)
Else
intDay = 28 - Math.Abs(intDay)
End If
End Select
intMonth = intMonth - 1
End If
If intMonth < 0 Then
intMonth = 12 - Math.Abs(intMonth)
intYear = intYear - 1
End If
Return IIf(intYear <> 0, intYear & " Years ", "") & _
IIf(intMonth <> 0, intMonth & " Months ", "") & _
IIf(intDay <> 0, intDay & " Days", "")
End Function
Public Function CalcAge(ByVal BirthDate As Object) As Long
'returns only years
If Not IsDate(BirthDate) Then Exit Function
Dim dtTemp As Date
dtTemp = CDate(BirthDate)
If dtTemp > Now Then Exit Function
Return DateDiff("yyyy", dtTemp, Date.Now) + (DateSerial(Year(Date.Now), _
Month(dtTemp), dtTemp.Day) >= Date.Now)
End Function
```