Solved

Masked Edit Box

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

733 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