Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

check date validation

Posted on 1999-07-27
4
Medium Priority
?
169 Views
Last Modified: 2012-08-14

Dear Experts,
      
      i am trying to enter valid date in maskedit text box. for that i write following code:
      
      maskedit1.format = "dd-mm-yyyy"
      maskedit1.mask = "##-##-####"

      when i enter date like 12-15-1999 in that maskeditbox, instead of giving error it changes to 15-12-1999 automatically. so how can i prevent user to enter invalid date. means how can i check validity of date. i think you understand my problem...

      so please give some information with code if possible.

TIA,
From Tushar
0
Comment
Question by:tushar_kapadi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:pietjepuk
ID: 1527757
With 12-15-1999 the format is clear because there is no fifteenth month. Basically there is no way of preventing a user typing 01-02-1999 when he/she means 02-01-1999 in a textbox because both are valid dates.

A way of preventing this is to use the calendar control. This control always returns the chosen date in the same format.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1527758
Add a third m to the format statement and then you'll name the month. Use ISDATE to validate.

M

0
 
LVL 10

Accepted Solution

by:
caraf_g earned 40 total points
ID: 1527759
pietjepuk? :-)

Don't use the date functionality in the masked edit box. It gives you all the lovely <bah> VB functionality, such as interpreting something with 12, 15 and 1999 in it always as 15 December 1999, whether the user used the correct format or not.

Instead, just use the correct ##-##-#### mask, but do the validation yourself.
0
 
LVL 1

Expert Comment

by:pietjepuk
ID: 1527760
I was a bit too quick answering the question before reading it.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question