|
-
Mar 6th, 2002, 09:03 AM
#1
Thread Starter
Frenzied Member
Date validation
I have a text box, into which the user has the opportunity of entering a date.
What is the best code to use to:
a) validate to ensure the date is correct
b) translate whatever they have entered into a standard format date.
a) should reject 13/13/2002 etc.
b) should sort out the problems of either 13/12/2002 or 12/13/2002 is valid, but not both.
-
Mar 6th, 2002, 09:05 AM
#2
Member
Trying using isdate(text1.text) and converting the string to a date data type cdate(text1.text) assumimg isdate returned true.
-
Mar 6th, 2002, 09:17 AM
#3
Bouncy Member
you could opt to use the MaskedEdit control (microsoft), you can specifiy an input mask for the user. It's good.
-
Mar 6th, 2002, 09:19 AM
#4
Thread Starter
Frenzied Member
THANKS.
IsDate is true for both 13/6/02 and 6/13/02
And the CDate always translates it to 13/06/2002
-
Mar 6th, 2002, 10:17 AM
#5
Member
this depends on the localised settings on the PC, you could use in combination with the format function.
-
Mar 6th, 2002, 10:29 AM
#6
My dog ate my harddrive...You don't believe me? Well...*SLAP*
Why not just use a date picker control? They ship with VB. They can be found under Windows Common Controls 6.Blah...
If you enter a date into a textbox it can be in the form of:
Day/Month/Year
or
Month/Day/Year
or
Day/Year/Month
or
Year/Day/Month
or
Year/Month/Day
or
Month/Year/Day

Oh, and it all depends on what your system date format is set to. Goto Regional Settings in your control panel to find out.
Using a datePicker control automatically removes any errors you may get by using dates and having them formatted wrongly...Loads easier.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|