Vb Program To Calculate Age
G'day, I am looking at upgrading my laptop however the majority of ones I am looking at come with 4 GB of RAM and Windows 7 (64 bit) to make use of.
Calculating of age by year,months. Beginner in visual basic.net 2008 i want to. Day,and the third is for the year and i have one button for calculating.
Vb Program To Calculate Area Of A Circle
Calculating someone's age, given that person's birth date, is a commonplace need in data manipulation. Unfortuntaely, VBA doesn't give a complete and correct method for calculating a person's age. You might be tempted to use this formula: Age = DateDiff('yyyy', Birthdate, Date) to calculate age, but this doesn't quite work. If the birth date hasn't yet occurred this year, the Age value will be off by 1. For example, imagine your birthday is December 31, and you were born in 1950. If today is October 1, 1997, subtracting the year portions of the two dates (1997 – 1950) would indicate that you were 47 years old. In reality, by the standard way of figuring such things, you're still only 46.
To handle this discrepancy, the dhAge function in Listing 2.22 not only subtracts one Year portion of the dates from the other, it checks whether the birth date has already occurred this year. If it hasn't, the function subtracts 1 from the calculation, returning the correct age.
In addition, dhAge allows you to pass an optional second date: the date on which to calculate the age. If you pass nothing for the second parameter, the code assumes you want to use the current date as the ending date. That is, if you use a call like this: intAge = dhAge(#5/22/59#) you'll find the current age of someone born on May 22, 1959.
If you call the function like this: intAge = dhAge(#5/22/59#, #1/1/2000#) you'll find out how old the same person will be on the first day of 2000. Listing 2.22: One Solution for Calculating Age Function dhAge(dtmBD As Date, Optional dtmDate As Date = 0) As Integer ' This procedure is stored as dhAgeUnused in the sample ' module. Dim intAge As Integer If dtmDate = 0 Then ' Did the caller pass in a date? If not, use ' the current date. DtmDate = Date End If intAge = DateDiff('yyyy', dtmBD, dtmDate) If dtmDate.