Reading DOB text string to find specifically year?

oreilly
05-23-2012, 05:22 AM
Hello guys,
I'm working on a Software Design & Development assignment, part of it is reading in a .csv file with records of student info.

This particular form is intended to work by the user selecting gender and age from a combo box which causes a listbox to be filled with names of students from the Db respective to the aforementioned settings.

I'm trying to work out how the Age combo selection will work as the only way of finding age is by the date of birth record (StudentInfo(x).DOB)

So after the year of birth is found a Select Case will need to be put in to link the year with the respective age value (e.g 1994 = 18).

I'm fairly novice at Visual Basic just so you know. I've been using it for 3-4 years(I'm in Year 12) however this is high school skill level and we don't really learn a lot over those three years.

dilettante
05-23-2012, 06:14 AM
Er, there is more to calculating a person's age than their birth year subtracted from the current year.

You might look at the DateDiff() function.

Gender and Age in one combo? Weird.

oreilly
05-24-2012, 12:57 AM
In the case of a program for an Athletics Carnival all you need is their birth year because they'd come under the under 13's, under 14's, under 15's etc.

Also, well picked there, gender and age are two different ComboBoxes actually.
Hopefully this DateDiff() function will be what I'm looking for though :)

dilettante
05-24-2012, 02:33 AM
My thought was that if somebody was 13 but just turned 14 last week you'd want to give them "full credit" for being 14 now. So you'd want to calculate age as the difference between today and their birth date in years, truncating to whole years, as in:

Age = Fix(DateDiff("yyyy", BirthDate, Date))

And in case it's vague, Date there is actually an intrinsic function that returns the current date.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum