- Home
·
- Miscellaneous
·
- This will calculate the age(no of years, no of months, no of days) of a person depending on his bir
This will calculate the age(no of years, no of months, no of days) of a person depending on his bir
This will calculate the age(no of years, no of months, no of days) of a person depending on his birthday
Rate This will calculate the age(no of years, no of months, no of days) of a person depending on his bir
(1(1 Vote))
Dim vdt1 As Date
Dim vdt2 As Date
vdt1 = Format(dtpstart, "dd/mm/yyyy")
vdt2 = Format(dtpend, "dd/mm/yyyy")
If vdt1 > vdt2 Then
MsgBox " Starting year Cannot be greater then Ending Year"
Else
Call CalcAge(vdt1, vdt2)
End If
End Sub
Public Sub CalcAge(vDate1 As Date, vdate2 As Date)
Dim vYears As Integer, vMonths As Integer, vDays As Integer
vMonths = DateDiff("m", vDate1, vdate2)
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)
If vDays < 0 Then
vMonths = vMonths - 1
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)
End If
vYears = vMonths \ 12 ' integer division
vMonths = vMonths Mod 12 ' only want leftover less than one year
txtdiff.Text = " Filed on - " & Format(vDate1, "dd/mm/yyyy") & vbCrLf & vbCrLf & " Disposed of on - " & Format(vdate2, "dd/mm/yyyy") & vbCrLf & vbCrLf & " Duration - Years - Months - Days: " & vbCrLf & vbCrLf & vbTab & vbTab & vYears & vbTab & vMonths & vbTab & vDays
End Sub
This will calculate the age(no of years, no of months, no of days) of a person depending on his bir Comments
No comments yet — be the first to post one!
Post a Comment