?
Solved

How do you check if a maskedtextbox control is empty ?

Posted on 2006-11-23
8
Medium Priority
?
1,087 Views
Last Modified: 2008-02-01

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 ...
0
Comment
Question by:Kinger247
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 34

Expert Comment

by:Sancler
ID: 18002601
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
 
LVL 13

Accepted Solution

by:
newyuppie earned 2000 total points
ID: 18002646
if you use something like this:

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

does that work?
NY
0
 
LVL 5

Expert Comment

by:DEEPESH
ID: 18002944
USe MaskedTextBox1.TextMaskFormat property
hope it works for u
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 63

Expert Comment

by:Fernando Soto
ID: 18003154
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
 
LVL 10

Author Comment

by:Kinger247
ID: 18003163
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
 
LVL 13

Expert Comment

by:newyuppie
ID: 18003195
oops, sorry about that. you can ask for refund no?
0
 
LVL 10

Author Comment

by:Kinger247
ID: 18003199
no, its ok, ... my fault.. I've just reposted.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question