by Ulysses R. Gotera (9 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sat 15th March 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Do you want to find out the accurate age of a person? This code will help you compute for the exact age of a person.
ByVal dteto As Date) As Integer
' Author: Ulysses R. Gotera
' Email: [email protected]
' Note: Please send me an e-mail wether I had helped you or
' comment(s) about this code. I definetly love feed back.
' I hope this code will help you solve any of your programming problems.
' Kindly indicate also if you are a student or professional. Thanks.
On Error GoTo ErrHandler
Dim intFromDay As Integer, intFromMon As Integer, intFromYr As Integer
Dim intToDay As Integer, intToMon As Integer, intToYr As Integer
Dim intResultAge As Integer
intFromYr = Year(dtefrom)
intFromMon = Month(dtefrom)
intFromDay = Day(dtefrom)
intToYr = Year(dteto)
intToMon = Month(dteto)
intToDay = Day(dteto)
If intFromYr <= intToYr Then
intResultAge = intToYr - intFromYr
Else
udfAccurateAge = -1: Exit Function '// invalid value
End If
If intFromMon <= intToMon Then
If (intFromMon = intToMon) And (intFromDay > intToDay) Then
intResultAge = intResultAge - 1
Else
intResultAge = intResultAge
End If
Else
intResultAge = intResultAge - 1
End If
udfAccurateAge = intResultAge
udfAccurateAgeExit:
Exit Function
ErrHandler:
udfAccurateAge = -1
End Function
No comments have been posted about Do you want to find out the accurate age of a person? This code will help you compute for the exact. Why not be the first to post a comment about Do you want to find out the accurate age of a person? This code will help you compute for the exact.