-
Hi,
I have a text box that I only want a date entered in to. But, what else I would like to do is as the user is typing, the / signs automatically get placed after the month and year..
It's just kindof a nice feature to have and I have seen it done before.. Access seems to have this built in but I can't figure it out in VB6.
I understand that there might be a control that does this, but would rather do it in code so I don't have to distribute another control..
Thanks,
Dan
-
In thinking about my question some more, forget about automatically entering the / signs.. I guess it's not like a phone number where it is a fixed number of digits..
But, what I would like is some code that checks to make sure the user entered a valid date and if not, pop up a msgbox..
Thanks,
DAn
-
Code:
Private Sub Text1_LostFocus()
'IsDate checks if the expression is a valid date
If IsDate(text1.text) = False Then
MsgBox "Please enter a valid date
End if
End sub
'>>>USAGE<<<
'IsDate("hahaha") = False
'IsDate(22-22-00) = False
'IsDate(021000) = False
'IsDate("02.10.00") = True
'IsDate(02-10-00) = True
'IsDate(02/10/00) = True
[Edited by Jop on 10-02-2000 at 01:13 PM]
-
<?>
Replace the textbox with a MaskEdBox
Set the MaskedBox Mask property to ####/##/##
Include literals
then nothing but nambers can be entered and the
box will read yyyy/mm/dd