Hi friends ,
I want to Validate a date entered by a user in a text box
in mm/dd/yyyy format.help me out guys.i have tried the following code
but of no use.Its urgent.
Private Sub txtdate_LostFocus() ''''LOST FOCUS OF TEXTBOX
On Error GoTo errhandler
txtdate = Format(txtdate, "mm/dd/yyyy")
a = DatePart("m", txtdate)
b = DatePart("d", txtdate)
c = DatePart("yyyy", txtdate)
If Val(a) >= 13 Or Val(b) > 31 Or Val(c) > 2011 Then
MsgBox "Invalid Date"
txtdate.SetFocus
Else
End If
Exit Sub
errhandler:
If Err.Number = 13 Then
MsgBox "Invalid Date"
txtdate.SetFocus
End If
End Sub
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [email protected]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/