How do I compare two textboxes if they have text in them.

I have a text box called LastName and a MaskedTextBox for a date entry. I need to compare the two and if both textboxes have characters in them I need to generate a message. The following code is what I've tried and it doesn't work.
If LastName.Text IsNot Nothing And DOB.Text IsNot Nothing Then
    MsgBox("You can only search with Last Name or DOB!")
    Exit Sub
End If

Open in new window

Who is Participating?
whsumConnect With a Mentor Commented:
If LastName.Text <> "" And DOB.Text <> ""

Will that work?
try using String.Empty
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.