Gotta Agree Tim

Khateeb, use the IsDate Function
-------------
Private Sub txtdate_LostFocus()          ''''LOST FOCUS OF TEXTBOX
If IsDate(txtDate.Text) Then
        txtdate.Text = Format(txtdate.Text, "mm/dd/yyyy")
        Else
        MsgBox "Invalid Date"
        txtdate.SetFocus
        End If
End Sub
-------------

BTW - You would be better off using the Validate Event instead of LostFocus

Regards

MikeB

> -----Original Message-----
> From: Tim Rupp [mailto:[EMAIL PROTECTED]
> Sent: 12 September 2005 20:40
> To: [email protected]
> Subject: RE: [vbhelp] Need Urgent Help
> 
> 
> Hello friend,
> 
> So what is of no use? 
> 
> Could you perhaps elaborate on your problem with this routine.
> 
> BTW, it doesn't seem very urgent to me.
 _____  
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] 
> On Behalf Of
> khateeb
> Sent: Monday, September 12, 2005 1:29 PM
> To: [email protected]
> Subject: [vbhelp] Need Urgent Help
> 
>  
> 
> 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
> 
> 
> 
> 
> 
> 
> 
> '// =======================================================
>     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 
> 
>  
> 
> *      Visit your group "vbhelp 
> <http://groups.yahoo.com/group/vbhelp> "
> on the web.
>   
> *      To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> 
>   
> *      Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/>  Terms of Service. 
> 
>  
> 
>   _____  
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> --------------------~--> 
> Most low income households are not online. Help bridge the 
> digital divide today!
> http://us.click.yahoo.com/cd_AJB/QnQLAA/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
> 
> 
> 
>  
> 
> 


------------------------ 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/
 



Reply via email to