Help Clearing data in MaskEditBox Control

  • Thread starter Thread starter jamesburkett
  • Start date Start date
J

jamesburkett

I'm trying to clear text from a MaskEditBox control.

I thought the format to delete it was:

'clear the mask
mskName.Mask = ""
'clear the text
mskName.Text = ""
'reassign the mask
mskName.Mask = "##:## ??"


this doesn't seem to work... what am I doing wrong? Thanks.
 
I don't think you need to clear the mask, you should be able to just
use
mskName.Text = ""

Thanks,

Seth Rowe
 
Yeah, that didn't work either... actually... on all of my masked edit
boxes, it isn't recognizing the .text property as anything other than
"". Any ideas there? Thanks!
 
Does it throw an error when you try to set the .Text property? Also,
have you tried stepping through the code to make sure that nothing is
interfering?

Thanks,

Seth
 
I've stepped through about 15 times.... I can't figure it out, but I'm
gonna go into my professor today. Tahnks for the help though.
 
ok, i've got an update....

to clear the mskeditbox you have to:
mskName.Mask = " "
'there must be a space
mskName.Text = " "
mskName.Mask = "#####"

but it's weird because it still doesn't register the mask.text to have
anything in it.... anyone have any ideas? Thanks.
 
and I figured the rest out... ok

the .text property is not recognized by the mskeditbox so you must use
the .seltext but you must follow this format:

mskZip.SelStart = 0
mskZip.SelLength = Len(mskZip.Mask)
strZip = mskZip.SelText
 
Hello james,
I'm trying to clear text from a MaskEditBox control.

I thought the format to delete it was:

'clear the mask
mskName.Mask = ""
'clear the text
mskName.Text = ""
'reassign the mask
mskName.Mask = "##:## ??"
this doesn't seem to work... what am I doing wrong? Thanks.

Since you are refering to the MaskEditBox, I assume you are working with
VB6 as the 2005 version is the MaskedTextBox. If it is the VB6 version, you
may want to try one of the VB6 groups. FWIW, here's the code I used on my
wrapped box:

Public Property Let Text(ByVal New_Text As Variant)
Dim stMask As String
'clear out old value
mflgLoading = True
stMask = MaskEdBox1.Mask
MaskEdBox1.Mask = ""
MaskEdBox1.Text = ""
MaskEdBox1.Mask = stMask
'put data in box
If IsNull(New_Text) = False Then
Select Case stMask
Case "##/##/####", "&&/&&/&&&&"
MaskEdBox1.SelText = Format(New_Text, "mm/dd/yyyy")
Case Else
MaskEdBox1.SelText = New_Text
End Select
End If
PropertyChanged "Text"
mflgLoading = False
RaiseEvent Change
End Property

My full sample is available at http://avbsg.net/Uploads/JW071801.exe. (note,
this is actually a zip file not exe. You will need to change the extension
in order for it to extract properly).

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
Back
Top