Solved

Masked Edit Box

Posted on 2002-07-01
3
943 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
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 25 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now