Solved

How do you check if a maskedtextbox control is empty ?

Posted on 2006-11-23
8
1,071 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
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 500 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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 10

Author Comment

by:Kinger247
ID: 18003183
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 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