Validating Dates and Times
Posted on 2011-04-20
Hi, I'm using VB.NET2010, WinForms. I have a series of dates and time values that I read in from a text file. I parse them and then I do some calculations with them. -- All that is OK.
However, I had one date that was 05/D/2010...obviously, that was some sort of glitch in my text file, but that still was a problem. I'd like to make sure my dates are really dates and my time values are really time values.
My formats are as follows:
Time: hh:mm:ss tt
Here is some sample data for each.
I would like to flag the values that are invalid, perhaps something like this:
If Not Date.value is valid date Then
Replace the date value with a date of "99/99/9999" (or something similar)
Same for the time value.
Or is there a better way?
Thanks for the help,