- Home
·
- Math/Dates
·
- This code will determine the age of a person given the date of birth. There are two procedures give
This code will determine the age of a person given the date of birth. There are two procedures give
This code will determine the age of a person given the date of birth. There are two procedures given for you to choose from.
Rate This code will determine the age of a person given the date of birth. There are two procedures give
(1(1 Vote))
'year value of the two dates
Private Function ComputeAge1(ByVal bdate As Date) As Integer
ComputeAge1 = Year(Date) - Year(bdate)
End Function
'This will compute an exact age considering the actual day of birth
Private Function ComputeAge2(ByVal bdate As Date) As Integer
Dim y As Integer
y = Year(Date) - Year(bdate)
If Month(Date) > Month(bdate) Then
y = y - 1
ElseIf Month(Date) = Month(bdate) Then
If Day(Date) < Day(bdate) Then y = y - 1
End If
ComputeAge2 = y
End Function
This code will determine the age of a person given the date of birth. There are two procedures give Comments
No comments yet — be the first to post one!
Post a Comment