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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to clear a mask edit box with a date

Status
Not open for further replies.

eelsar

Technical User
May 20, 2002
36
US
I am having the following problem.

At run-time I mask the mask edit box date format mm/dd/yy ("##/##/##"). However if the user enters an invalid date such as 99/88/77 then I want to clear the mask edit box.

This is what I did
Private Sub maskDate1stLetter_LostFocus()
If Not IsDate(maskDate1stLetter.Text) Then
MsgBox "Invalid Date", vbExclamation
End If
End Sub

In the LostFocus how do I empty the mask edit box so the user can re-enter the date?
Thank you!
 
'I think this is what you mean. I hope you find it helpful.
'---------------------------------------------------------

Private Sub MaskEdBox1_GotFocus()
MaskEdBox1.SelStart = 0
MaskEdBox1.SelLength = 10
End Sub
'---------------------------------------------------------
Private Sub MaskEdBox1_LostFocus()
Dim OldMask As String
If Not IsDate(MaskEdBox1.Text) Then
OldMask = CStr(MaskEdBox1.Mask)
MaskEdBox1.Mask = ""
MaskEdBox1.Text = ""
MaskEdBox1.Mask = OldMask
MaskEdBox1.Refresh
MaskEdBox1.SetFocus
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top