JTUP JTUP - 1 year ago 100
Vb.net Question

How to validate a null value in a maskedtextbox phone number input mask

I want to check for null values. using this code below. i am still getting values in the textbox. The values i am getting in the textbox are "( ) -"...

If Text_Phone.Text IsNot "" Then
If BuildSqlFlag = True Then
BuildSql = BuildSql & " AND " & "Phone = " & Text_Phone.Text
BuildSql = "Phone = " & Text_Phone.Text
End If
BuildSqlFlag = True
End If

i am not exactly sure what is needed from my code to be changed to i even tried the following:

If Text_Phone.Text IsNot "( ) -" Then

But that was no help.


Set the TextMaskFormat to exclude prompt and literals.

Text_Phone.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals

MaskFormat Enumeration

Then when you do Text_Phone.Text it will be equal to "" if it's empty.