Solved

Masked Edit Box

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now