Validate Masked Input Text Box

How do I validate to see if a value has been entered into a masked input box.

Thanks

   If txtDOB.CtlText = "" Then
            MsgBox("Please enter DOB")
            txtDOB.Focus()
            Exit Sub
        End If
running32Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
for dates, you should really use a DateTimePicker control.

For other mask, see http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp
Bob LearnedCommented:
Regular expression validation.

Bob
running32Author Commented:
Thanks guys
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

running32Author Commented:
Sorry I hit enter too quickly.

Regular validation does not work.  Even when I enter a value I get the msgbox.

 If txtDOB.Text = "" Then
            MsgBox("Please enter DOB")
            txtDOB.Focus()
            Exit Sub
        End If

and I would rather not use a datetime picker control.  Thanks for the input
Éric MoreauSenior .Net ConsultantCommented:
what about the mask edit control ?
running32Author Commented:
I wanted to validate that there is actually a value in the text box before I proceed.  My problem is that because it is masked I'm not sure how to test.
running32Author Commented:
I tried this below and I can see the string as 08/17/1975 but it does not reconize there are # there

 Dim instrdob As Integer
        instrdob = InStr(1, txtDOB.CtlText, "[0-9]", CompareMethod.Text)
        If instrdob = 0 Then
            MsgBox("Please enter DOB")
            txtDOB.Focus()
            Exit Sub
        End If
Éric MoreauSenior .Net ConsultantCommented:
You are already using a masked edit control! Which one is it?

I suppose that the CtlText property you are using gives you the prompts characters (/-_ ...). You must have another property that exclude them (this property is different from each control). Add you control to the Watch window while it as no value in it and check to see which property as the raw value in it.
running32Author Commented:
I'm new to vb.net.  I'm using the Masked EditControl Version 6.0 if that helps any.  In the mask session I put ##/##/####.

I'm not sure how to add the control to the Watch window.  But if I display a message box I get back __/___/____ and the value count is always 10.

Thanks
Éric MoreauSenior .Net ConsultantCommented:
You should really avoid using ActiveX controls into .Net.

As in VB6, you can use the ClipText property to get the raw data out of the Mask Edit control.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
running32Author Commented:
ClipText it is. Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.