Solved

How do you check if a maskedtextbox control is empty ?

Posted on 2006-11-23
8
1,068 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 62

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

786 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