How do you check if a maskedtextbox control is empty ?


I have a mask of : 00/00/0000 90:00

But need to check if its empty, the .text property returns "__/__/____ __:__"

So I can't check to see if the text = the original mask.

I'm close to pulling my hair, and I don't have allot left ... help !

There must be some logic I'm missing ...
LVL 10
Kinger247Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
newyuppieConnect With a Mentor Commented:
if you use something like this:

If String.IsNullOrEmpty(MaskedTextBox1.Text) Then
   MessageBox.Show("Im Empty")
End If

does that work?
NY
0
 
SanclerCommented:
This is working for me

    Private Sub mtb_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mtb.TextChanged
        If mtb.Text = "  /  /       :" Then
            Debug.WriteLine("Empty")
        Else
            Debug.WriteLine("Not empty")
        End If
    End Sub

Roger
0
 
DEEPESHCommented:
USe MaskedTextBox1.TextMaskFormat property
hope it works for u
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Fernando SotoRetiredCommented:
Hi Kinger247;

        If MaskedTextBox1.Text = "__/__/____ __:__" Then
            Console.WriteLine("Masked Text Box Is Empty")
        Else
            Console.WriteLine(Masked Text Box Is NOT Empty)
        End If

Fernando
0
 
Kinger247Author Commented:
Would you believe I closed the wrong question .... I'll reopen...

newyuppie, you got some free points !
But alas, your code didn't work.
0
 
newyuppieCommented:
oops, sorry about that. you can ask for refund no?
0
 
Kinger247Author Commented:
no, its ok, ... my fault.. I've just reposted.
0
All Courses

From novice to tech pro — start learning today.