Public Function Age(ByVal Birthdate As System.DateTime) As Long
Try
Dim CurrentDate As System.DateTime = System.DateTime.Today
Select Case Month(Birthdate)
Case Is < Month(System.DateTime.Today)
Age = DateDiff("YYYY", Birthdate, Now())
Case Is = Month(CurrentDate)
Select Case (Birthdate.Day)
Case Is < (CurrentDate.Day)
Age = DateDiff("YYYY", Birthdate, Now())
Case Is = (CurrentDate.Day)
Age = DateDiff("YYYY", Birthdate, Now())
Case Is > (CurrentDate.Day)
Age = DateDiff("YYYY", Birthdate, Now()) - 1
End Select
Case Is > Month(CurrentDate)
Age = DateDiff("YYYY", Birthdate, Now()) - 1
Case Else
Age = 0
End Select
Catch ex As System.Exception
'Error handling code does here
End Try
End Function