Working with dates
-
HI guys, I'm a student and need some help with dates in VB.NET. What do I do to verify that date values are input correctly on a form? This includes the following: The day, month and year are entered separately; One cannot (obviously!) be born on day 0 of month 13, or on 29 February 2003. I've never worked with dates and don't know how to go about this. Can someone please help me here? MichMar
-
HI guys, I'm a student and need some help with dates in VB.NET. What do I do to verify that date values are input correctly on a form? This includes the following: The day, month and year are entered separately; One cannot (obviously!) be born on day 0 of month 13, or on 29 February 2003. I've never worked with dates and don't know how to go about this. Can someone please help me here? MichMar
With the day, month and year being inserted separately ... it can be easy to check. some normal logic You will ask the year first because of leap years and stuff. Next the month will be enetered in
if EnteredMonth > 0 and EnteredMonth < 13 then 'month is a correct month else 'month is not correct end if
then when u know the month you can demine if the month has 30/31/28 or 29 days and the day can be checked to see if it falls in the bounds here is just a basic layout that you can change to suit your variables ect .. i think that more than explains it how i would go about itif year = leapyear then else ' not a leap year if month = 4 or month = 6 the 'all the months that have 30 days if enteredday > 0 and enteredday < 31 then 'date is correct else 'error end if end if if month = 5 or month = 3 then 'all the months that have 31 days if enteredday > 0 and enteredday < 32 then 'date is correct else 'error end if if month = 2 then 'month is feburary end if end if end if
-
HI guys, I'm a student and need some help with dates in VB.NET. What do I do to verify that date values are input correctly on a form? This includes the following: The day, month and year are entered separately; One cannot (obviously!) be born on day 0 of month 13, or on 29 February 2003. I've never worked with dates and don't know how to go about this. Can someone please help me here? MichMar