iamhx
iamhx

Reputation: 472

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?

Upvotes: 0

Views: 423

Answers (1)

Andy G
Andy G

Reputation: 19367

    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

Upvotes: 1

Related Questions