I have a form with 4 different dates that is not mandatory. I want to validate a date if one is selected and if a date is not selected i want to insert "1900-01-01" into the database. Below is my if statement but it is not working correctly:
Dim dtpDateReceived As Date = New Date
Dim dtpDateAssessed As Date = New Date
Dim dtpDateManufactured As Date = New Date
Dim dtpCustomerBuildDate As Date = New Date
txtDateRecieved.Text = "1900-01-01"
txtDateAssessed.Text = "1900-01-01"
txtDateManufactured.Text = "1900-01-01"
txtCustomerBuildDate.Text = "1900-01-01"
If Not Date.TryParse(txtDateRecieved.Text, dtpDateReceived) Then
lblMessageError.Visible = True
lblMessageError.Text = "Incorrect Date Recieved"
ElseIf Not Date.TryParse(txtDateAssessed.Text, dtpDateAssessed) Then
lblMessageError.Visible = True
lblMessageError.Text = "Incorrect Date Assessed"
ElseIf Not Date.TryParse(txtDateManufactured.Text, dtpDateManufactured) Then
lblMessageError.Visible = True
lblMessageError.Text = "Incorrect Date Manufactured"
ElseIf Not Date.TryParse(txtCustomerBuildDate.Text, dtpCustomerBuildDate) Then
lblMessageError.Visible = True
lblMessageError.Text = "Incorrect Customer Build Date"
Else
mCR.InsertClaimReturn(....)
End If