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
Solved

Masked Edit Box

Posted on 2002-07-01
3
949 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 connector to mongodb 2 118
TT Auto Dashboard 13 95
Export PDF Form fields to Access  or Excel  in Tab order 16 79
Error with a code discussed on this page 5 31
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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