Carl R Carl R - 3 months ago 14
Vb.net Question

If datetimepicker value greater than end datetimepicker value then

I am trying to write an if statement for two datetimepickers. I have a start date and end date and I do not want the value of the start date to be greater than the end date.

Here is what I have tried but doesn't work:

If dateStart.Value.Date < dateend.Value.Date Then

lblstatus.Text = "Status: Start date must be a date before end date."

Else

End If

Answer

Your Operator is wrong .. it should be greater than, not less than :)

    If dateStart.Value.Date > dateend.Value.Date Then

        lblstatus.Text = "Status: Start date must be a date before end date."

    Else