|
-
Jan 31st, 2007, 01:00 AM
#1
Thread Starter
Addicted Member
[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
-
Jan 31st, 2007, 01:32 AM
#2
Member
Re: Check Date Format input
Use ToDate and IsDate function....
-
Jan 31st, 2007, 01:33 AM
#3
Thread Starter
Addicted Member
Re: Check Date Format input
i never used these function.. could u show the code??
-
Jan 31st, 2007, 01:51 AM
#4
Member
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
-
Jan 31st, 2007, 02:24 AM
#5
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
-
Jan 31st, 2007, 02:46 AM
#6
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!
-
Jan 31st, 2007, 04:10 AM
#7
Thread Starter
Addicted Member
Re: Check Date Format input
rep added
thanks man.. will check it out.. looks pretty nice
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|