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.SelectedValu e
var_saildate = var_saildate + "/" + FrmDD_SailDay.SelectedValu e
var_saildate = var_saildate + "/" + FrmDD_SailYear.SelectedVal ue
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
Dim var_saildate As String
var_saildate = FrmDD_SailMon.SelectedValu
var_saildate = var_saildate + "/" + FrmDD_SailDay.SelectedValu
var_saildate = var_saildate + "/" + FrmDD_SailYear.SelectedVal
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
var_saildate = var_saildate + "/20" + FrmDD_SailYear.SelectedVal ue
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked perfect, thanks!