Masked Edit Box control? It's in MSMASK32.OCX Usage instructions are in VBHelp
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
The best way to get date input is to use the DateTimePicker that comes with the WindowsCommon Controls OCX shipped with VB. You'll find it in the components gallery under "Microsoft Windows Common Controls 2" (or maybe 3?)
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
i try to avoid this particular control. i generally find it doesn't act as i want it to (of course, i may be misunderstanding how it works!)
you may find this code useful. i use it with ordinary textboxes whose maxlen is set to 8 (dd/mm/yy). it allows a user to only input numeric characters and the "/" appears automatically in the correct place. i don't use placeholders, but that could be coded in. finally, i check that the date is valid (don't rely on IsDate - you may get unexpected results) - but that validation isn't here.
Private Sub DateMask(ctl As Control, KeyAscii As Integer)
'because vb's mask control is not up to the task
Dim strChar As String * 1
strChar = Chr(KeyAscii)
If KeyAscii = 47 Or KeyAscii = 46 Then KeyAscii = 0 'cancel a user-input "/" or "."
If IsNumeric(strChar) Then
If Len(ctl) = 1 Or Len(ctl) = 4 Then
KeyAscii = 0
ctl = ctl & strChar & "/"
ctl.SelStart = Len(ctl)
End If
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.