Hello

My name is Scott and I'm a physician and software developer. I'm new to this web site so please be patient if I'm not doing things properly. I write a lot of applications where I frequently need to calculate a patient's age based on their date of birth. I tried to find good examples but in the past have failed so to make a long story short I have developed a complete application to calculate age and I'm enclosing a zipped copy for anyone to try. Please feel free to send comments to my email me drp@spmd.us. A copy can also be downloaded from my web site http://www.pace-med-apps.com/freeCode.aspx

Thank you
Scott E Pace MD

I will check it.

Hi,
I went through your code and there is an easier way to calculate the no. of years. You can simple use a builtin DateDiff function which takes Date1 and Date2 as paramters along with some other settings.

Hi,
I went through your code and there is an easier way to calculate the no. of years. You can simple use a builtin DateDiff function which takes Date1 and Date2 as paramters along with some other settings.

Hello
Actually if you check my code under the button "Less Accurate" you will see I did just that with the code:
Dim d1 As Date
Dim d2 As Date
d1 = Now
d2 = dtpDOB.Value
Dim iage As Integer
iage = DateDiff(DateInterval.Year, d2, d1)
txtAge.Text = CStr(iage)

This code is far less accurate.
Scott

Ok! I havnt tested the accuracy in details. But from my few tests both gave same results.

Nice work though! keep posting.

Nice work though! keep posting.

Thanks for the encouragement, Binoj!
Scott

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.