DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   How to check a valid date... (http://www.daniweb.com/forums/thread200546.html)

fernando82 Jun 29th, 2009 6:04 pm
How to check a valid date...
 
Hi everyone!
I have a problem related with dates.... i have some textbox where i put dates to send to a database... i have conditioned the input just for numbers and / (backslash), but how do i check that no one inserts a format that's not dd/mm/yyyy... if i put 1234 sends an error and stops

Thanks everyone!

wildgoose Jun 29th, 2009 7:27 pm
Re: How to check a valid date...
 
You have to parse each field and check to see if its legitimate.
Also check the day number to number of days in that month.
And double check if its a leap year or not.
You could parse and convert to Julian and store as a 32-bit number.
You may want to consider allowing dwarf entries so that for example today is 6/29/2009 but if someone enter 7/11 it will exchange 7/11 for 7/11/2009 automatically or with a verify! It gets very old having to enter a complete date every time!
You may consider a date split - six months vs + six months so that for example entry of past invoices allows a dwarf date!

vb5prgrmr Jun 29th, 2009 10:51 pm
Re: How to check a valid date...
 
IsDate anybody???

Good Luck

fernando82 Jun 30th, 2009 1:35 pm
Re: How to check a valid date...
 
Thanks to both of you!

The IsDate solution works perfectly... of course i'll check the other options, thanks!

kehar Jul 3rd, 2009 4:44 am
Re: How to check a valid date...
 
Add MS Mask Edit control in your form and under its Property go to
mask and enter ##/##/#### then
run the programme and give focus. you can enter your own date without using dtpicker.


All times are GMT -4. The time now is 8:59 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC