VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code will determine the age of a person given the date of birth. There are two procedures give

by Mark Pit (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 3rd December 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



'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

Download this snippet    Add to My Saved Code

This code will determine the age of a person given the date of birth. There are two procedures give Comments

No comments have been posted about This code will determine the age of a person given the date of birth. There are two procedures give. Why not be the first to post a comment about This code will determine the age of a person given the date of birth. There are two procedures give.

Post your comment

Subject:
Message:
0/1000 characters