Link to home
Start Free TrialLog in
Avatar of Nugs
Nugs

asked on

Catch bad date

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
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

var_saildate = var_saildate + "/20" + FrmDD_SailYear.SelectedValue
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nugs
Nugs

ASKER

That worked perfect, thanks!