?
Solved

Masked Edit Box

Posted on 2002-07-01
3
Medium Priority
?
969 Views
Last Modified: 2007-11-27
Hello experts:

I'm working with a masked edit box and I'm getting stumped on what should be something simple.

I have a masked edit box with the mask set to (###)###-####

This is used to capture a phone number.  However, if I'm navigating through records, I can't figure a way to clear out the phone field because it won't accept blanks.

Would someone offer some assistance on how to clear out this field?

Thanks
0
Comment
Question by:escheider
[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
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 100 total points
ID: 7122632
CLEAR A MASKED EDIT BOX
To blank out the text in a masked edit box, make sure the string you assign uses underscores
matching the mask. It's difficult to maintain code when you have to change a mask; you have
to find all the locations where you cleared the masked edit control in your code. To fix this problem,
simply get rid of the mask, clear the contents, then restore the mask. Use this subroutine to clear
the text of any masked edit box; just pass in the control:

Public Sub ClearMaskEdBox(oMaskEdBox As MaskEdBox)
     Dim sTemp As String
     With oMaskEdBox
          sTemp = .Mask
          .Mask = ""
          .Text = ""
          .Mask = sTemp
     End With
End Sub

'Sample Call:
Private Sub cmdClear_Click()
     ClearMaskEdBox MaskEdBox1
     MaskEdBox1.SetFocus
End Sub
0
 
LVL 4

Author Comment

by:escheider
ID: 7122646
I knew it had to be simple..thanks for the quick response..works like a champ
0
 

Expert Comment

by:capu_pibe
ID: 7526779
There is anohter way
If your mask property in the masked edit is like this
"#####", in the code to clean this masked edit box you have to use
     maskededit.text = "_____"
This, if the promptchar property is "_"

so the only thing that you have to do is to replace the text with the "empty mask" with only prompt chars.

For example

    Maskededitbox.mask = "(###)-##-##-##-##"
    Maskededitbox.promptchar = "_"
to clean the maskededit box you only have to put this code
   maskededitbox.text = "(___)-__-__-__-__"
and the maskededitbox will be cleaned
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

765 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