troubleshooting Question

Catch bad date

Avatar of Nugs
Nugs asked on
Visual Basic.NET
3 Comments1 Solution239 ViewsLast Modified:
I have a little piece of code that constructs a date and displays a error message if the date selected is less than the current date... This works perfect...

      Dim var_saildate As String
            var_saildate = FrmDD_SailMon.SelectedValue
            var_saildate = var_saildate + "/" + FrmDD_SailDay.SelectedValue
            var_saildate = var_saildate + "/" + FrmDD_SailYear.SelectedValue

            
                  If var_saildate < Now() Then            
                        lblBadDate.Text = "You have selected an sail date earlier than the current date<br>"
                        lblBadDate.Visible = "true"
                        dbConn.Close()
                        Exit Sub
                  Else


BUT

Say i select the date 01/31/09, It produces an error because this is not a valid date... How can i modify my code to catch such a error?

Nugs
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros