Date validation help

Rabid Lemming

New member
Joined
Feb 10, 2005
Messages
4
Programming Experience
Beginner
Hi,


I have a form in vb.net 2005 and I want to validate the users date of birth now I can do the is date function part like so:


VB.NET:
[color=blue][font=Courier New]Function[/font][/color][font=Courier New] CheckDateOfBirth() [color=blue]As[/color] [color=blue]Boolean[/color][/font]
[font=Courier New][color=blue]Try[/color][/font]
[color=blue][font=Courier New]Dim[/font][/color][font=Courier New] var13 [color=blue]As[/color] [color=blue]String[/color][/font]
[font=Courier New][color=green]'Set the inputs to a date like format[/color][/font]
[font=Courier New]var13 = txtDayOfPurchase.Text + "/" + txtMonthOfPurchase.Text + "/" + txtYearOfPurchase.Text[/font]
[font=Courier New][color=blue]If[/color] IsDate(var13) = [color=blue]False[/color] [color=blue]Then[/color][/font]
[font=Courier New][color=green]'If not a valid date return false[/color][/font]
[font=Courier New]CheckDateOfBirth = [color=blue]False[/color][/font]
[font=Courier New][color=blue]Else[/color][/font]
[font=Courier New]CheckDateOfBirth = [color=blue]True[/color][/font]
[font=Courier New][color=blue]End[/color] [color=blue]If[/color][/font]
[font=Courier New][color=blue]Catch[/color] ex [color=blue]As[/color] Exception[/font]
[font=Courier New]MsgBox(ex.Message, MsgBoxStyle.Exclamation, "")[/font]
[font=Courier New][color=blue]End[/color] [color=blue]Try[/color][/font]
[font=Courier New][color=blue]End[/color] [color=blue]Function[/color][/font]


The problem is I want to ensure the user is over 18

I also want to check to see if their DOB was in a leap year as I want to ensure that what ever they type in the system check the day and month and year and ensures that if that year they were born was a leap year that the day of the month they were born is valid. As in leap years some mouths have different amounts of days in them

I also need to validate a second date input were the user enters the date they wish to purchase something (they purchase in advance) again I need to ensure that the dated entered is valid if it’s a leap year or not. I also need to check that the day date enter in both cases is a valid date for that month so it the month only had 30 days in it the day value could not be grater than 30

I know this is asking a lot but any help would greatly be appreciated and I am willing to offer a small reward (via pay pal) to a full answer say £10 ?

Cheers
Rabid Lemming
 
Top Bottom