Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Masked Edit Control - clearing out contents 1

Status
Not open for further replies.

Pawn28

Programmer
Joined
Jul 22, 2005
Messages
4
Location
CA
Hi all,

I'm using the COM Masked Edit Control and I have it set up that whatever is typed in it will be added to my ListBox control with the click of a button. My problem is how to clear out the contents of the Masked Edit Control after I added the info to my ListBox.

Thanks
 
Pawn28,
Below is my old VB6 code, which you could probably turn into .NET. The code demonstrates 3 different ways to clear the box. Put 3 command buttons and one masked edit control on the form.

vladk

Private Const CLEAR_MASK As Long = 1
Private Const CLEAR_PROMPT_INCLUDE As Long = 2
Private Const CLEAR_REPLACE_PLACEHOLDERS As Long = 3

Public Sub ClearMaskEditBox(ByRef pMaskEdBox As MaskEdBox, ByVal plngHowToClear As Long)

Dim strMask As String
Dim blnPromptInclude As Boolean

Select Case plngHowToClear

Case CLEAR_MASK
With pMaskEdBox
strMask = .Mask
.Mask = vbNullString
.Text = vbNullString
.Mask = strMask
End With

Case CLEAR_PROMPT_INCLUDE
With pMaskEdBox
blnPromptInclude = MaskEdBox1.PromptInclude
.PromptInclude = False
.Text = MaskEdBox1.Mask
.PromptInclude = blnPromptInclude
End With

Case CLEAR_REPLACE_PLACEHOLDERS
With pMaskEdBox
.Text = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(.Mask, "&", .PromptChar), "#", .PromptChar), "?", .PromptChar), "A", .PromptChar), "a", .PromptChar), "9", .PromptChar), "C", .PromptChar), ">", vbNullString), "<", vbNullString)
End With
Case Else
ClearMaskEditBox pMaskEdBox, CLEAR_MASK
End Select

End Sub

Private Sub Command1_Click()
ClearMaskEditBox MaskEdBox1, CLEAR_MASK
End Sub

Private Sub Command2_Click()
ClearMaskEditBox MaskEdBox1, CLEAR_PROMPT_INCLUDE
End Sub

Private Sub Command3_Click()
ClearMaskEditBox MaskEdBox1, 6 'CLEAR_REPLACE_PLACEHOLDERS
End Sub
 
Hey thanks!

I will try this :)
 
BTW very bad idea to use the com one their are several good .net ones you can get for free.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top