954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Calculate Age in VB 2005

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 [EMAIL="drp@spmd.us"]drp@spmd.us[/EMAIL]. A copy can also be downloaded from my web site http://www.pace-med-apps.com/freeCode.aspx

Thank you
Scott E Pace MD

Attachments Calculate_Age.zip (66.84KB)
muskdial
Newbie Poster
6 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

I will check it.

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

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.

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 
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

muskdial
Newbie Poster
6 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

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

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

Nice work though! keep posting.

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

You can also download a free Email Extractor from any kind of File on the hard drive.
Download it from http://www.coderewind.com/?categ&view_article=24

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 
Nice work though! keep posting.


Thanks for the encouragement, Binoj!
Scott

muskdial
Newbie Poster
6 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You