[RESOLVED] Check Date Format input
Hi
I am taking a date input from a text box "txtdate.txt"
Now that should be in the format "mm/dd/yy" else it should give a error msg box saying " Enter correct format "
can any one help in writing this function??
also if not complicated can i also verify that the month added is correct( between 1 and 12) and the date value also between 1 and 31 in the same function??
thanks
Re: Check Date Format input
Use ToDate and IsDate function....
Re: Check Date Format input
i never used these function.. could u show the code??
Re: Check Date Format input
CDate function can convert a string to date
IsDate function checkes whether a string is date or not...
check this link...
http://msdn.microsoft.com/library/de...7d35c5d7ba.asp
Re: Check Date Format input
Hmm...
VB Code:
Private Sub Command1_Click()
If IsDate(txtDate.Text) Then
MsgBox "Date Accepted"
Else
MsgBox "Please Enter the correct Format"
End If
End Sub
Re: Check Date Format input
Ok here is a much better version...
VB Code:
Dim boolDate As Boolean
Private Sub Command1_Click()
boolDate = False
If IsDate(txtDate.Text) Then
If txtDate.Text Like Format("##/##/##", "mm/dd/yy") Then
MsgBox "Date Accepted"
boolDate = True
Else
boolDate = False
End If
Else
boolDate = False
End If
If Not boolDate Then
MsgBox "Please Enter the correct Format"
End If
End Sub
I see you want to validate the date and the format as well. Hope it helps! :)
Re: Check Date Format input
rep added
thanks man.. will check it out.. looks pretty nice