Avatar of Tom Knowlton
Tom Knowlton
Flag for United States of America asked on

Visual Basic 6 Function - is valid date?

I need complete working source code for Visual Basic 6 that allows you to pass in a text value and determine if the text value represents a valid date value.

Empty values are always VALID.  In other words, it is okay to leave the date BLANK.  But if you DO enter a value...it must be VALID.

Date values can be 6 characters long or 8 characters long ONLY.

Format will be MMDDYY or MMDDYYYY

//some_boolean_var = DateIsValid date_as_string

These calls would return TRUE

DateIsValid "" (empty string, no spaces)
DateIsValid "022912"
DateIsValid "02292012"




These would return FALSE

DateIsValid "-"
DateIsValid "&"
DateIsValid "&-"
DateIsValid " "  (one space)
DateIsValid "  "  (two (or more) spaces)
DateIsValid " 022912" (space (or some other char) before the otherwise valid date - even though removing the space would make the date valid - the space means this date fails)
DateIsValid "022912 " (space (or some other char) after the otherwise valid date)
DateIsValid "024912" (there is no 49th of February)
DateIsValid "022911" (2011 was not a leap year)
Visual Basic Classic

Avatar of undefined
Last Comment
Tom Knowlton

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tom Knowlton

ASKER
Thank you!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck