# How to compute the age of a person?For example, a person with birthday of 04/07/1984. using two textbox.?

whenyou enter your birthday in the first textbox, the next textbox will automatically compute for your age, it will appear it in said textbox, the code must be in vb.net. i really need ur help

thanx

Relevance
• Anonymous

I don't know what method you're talking about, but to find out the exact decimal, you take how many years old the person is, and add 0.X to it. X in this case is the number of days it's been since the person's last birthday, multiplied by 100, then divided by 365.25. With this equation, I can calculate that I am 21.58630136986301369863013698630137 years old. Nice, huh? lol

• Anonymous

One way would be something like this...

Dim birthday As Date

Dim age As TimeSpan

Dim ageinyears As Integer

birthday = Date.Parse(TextBox1.Text)

age = Now.Subtract(birthday)

ageinyears = CType(Math.Truncate(age.Days / 365.25), Integer)

TextBox2.Text = ageinyears.ToString

Of course, the variable names might change - and you should probably check for the user entering an invalid date.

• Anonymous