Kuyo Kuyo - 6 months ago 41
Vb.net Question

DateTimePicker validation for VB.net

I'm trying to do this:

If DateTimePicker1.Value.Date = DateTimePicker1.Value.Date Then
MessageBox.Show("You have not entered a date of birth yet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If


While my DateTimePicker value is
2016-01-01
, when passed all validation checks, The error above still shows up, even when I have changed the value of the date.

How does this happen?

Answer
    If DateTimePicker1.Value.Date = New Date(2016, 1, 1) Then
        MessageBox.Show("You have not entered a date of birth yet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Exit Sub
    End If