|
-
Oct 8th, 2001, 06:16 AM
#1
Thread Starter
Lively Member
Age Calculation
Hi everyone
trying to write a program to calculate and dispaly on a msgbox the age of an input birthdate and the current date. Tried this code below but not giving correct age.
StudentDate = cboDate.Text & "/" & cboMonth.Text & "/" lblYear.Caption
StudentAge = DateDiff("yyyy", StudentDate, Now())
If Month(Now) < cboMonth.Text Then
StudentAge = StudentAge -1
ElseIf Month(Now) = cboMonth.Text Then
If Day(Now) < cboDate.Text Then
StudentAge = StudentAge -1
End If
End If
This code makes the age correct if month is after the current month, but any date before the current month is a year out.
Thanks Tink
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|