|
-
May 19th, 2005, 04:55 AM
#1
Thread Starter
New Member
Date validation
Hi
Can anyone tell me how to validate a date entry in a text box. I want to ensure that the date is entered as 01/01/05 as opposed to 01.01.05 or 01-01-05. Alternatively can I set it up so that the "/" is placed automatically?
thanks
-
May 19th, 2005, 05:02 AM
#2
Re: Date validation
Use a MaskedEdit control instead of textbox. It provides all those features.
-
May 19th, 2005, 05:26 AM
#3
-
May 19th, 2005, 05:50 AM
#4
New Member
Re: Date validation
hi
you can use this code
VB Code:
Private Sub Text1_LostFocus()
Text1.Text = Format(Text1.Text, "dd/mm/yy")
End Sub
()
Last edited by fadi_r; May 19th, 2005 at 05:53 AM.
-
May 19th, 2005, 06:13 AM
#5
Re: Date validation
I think MaskedEdit control would be the best option....
-
May 19th, 2005, 07:40 AM
#6
Thread Starter
New Member
Re: Date validation
Thanks to all who replied. I will try out the various suggestions..please ignore the duplicate post
Thanks
Anne
-
May 19th, 2005, 08:38 AM
#7
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
May 19th, 2005, 09:07 AM
#8
Re: Date validation
 Originally Posted by fadi_r
hi
you can use this code
VB Code:
Private Sub Text1_LostFocus()
Text1.Text = Format(Text1.Text, "dd/mm/yy")
End Sub
()
Fadi_r,
Using your code try entering the following value into Text1: 010101
You will see that the function returns: 27/08/1927
It returns 27/08/1927 because then this date is 10,101 days greater that 30/12/1899 which I believe is the base date that windows uses to determine the date.
But if you enter 01/01/01 or 01/0/2001 then it will return 01/01/2001.
But I agree with the others a Datepicker is the way to go!
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
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
|