Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Date Validation?

I have a text box for dates. How do I validate whether it
is a date or not? I have tried the isDate() function and
it seems to return false sometimes and true other times. I
want to use either mm/dd/yy or mm/dd/yyyy format, it
doesn't matter. If anyone has used TaxCut, their textboxes
automatically places the "/" while typing and wont let you
put anything in other than a valid number, this forces the
correct mm/dd/yyyy format. Is this possible with VB.

Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Date Validation?

Hi

This is working for me

I will not leave the textbox until you fill in a date

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(TextBox1) = False Then
Cancel = True
MsgBox "Not a valid date."
Else
MsgBox "Valid date"
End If
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"R-Enemy" wrote in message ...
I have a text box for dates. How do I validate whether it
is a date or not? I have tried the isDate() function and
it seems to return false sometimes and true other times. I
want to use either mm/dd/yy or mm/dd/yyyy format, it
doesn't matter. If anyone has used TaxCut, their textboxes
automatically places the "/" while typing and wont let you
put anything in other than a valid number, this forces the
correct mm/dd/yyyy format. Is this possible with VB.

Thanks for any help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Date Validation?

Thanks, I'll try that. I think my problem might be that I
set a variable to the textbox.text and then did the isDate
function. Like this:

Dim a as String
if isDate(a) = false then
call msgbox("invalid date")
textbox1.setFocus
End if

I like the not being able to exit until valid. Thanks.


-----Original Message-----
Hi

This is working for me

I will not leave the textbox until you fill in a date

Private Sub TextBox1_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If IsDate(TextBox1) = False Then
Cancel = True
MsgBox "Not a valid date."
Else
MsgBox "Valid date"
End If
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"R-Enemy" wrote in

message ...
I have a text box for dates. How do I validate whether it
is a date or not? I have tried the isDate() function and
it seems to return false sometimes and true other times. I
want to use either mm/dd/yy or mm/dd/yyyy format, it
doesn't matter. If anyone has used TaxCut, their textboxes
automatically places the "/" while typing and wont let you
put anything in other than a valid number, this forces the
correct mm/dd/yyyy format. Is this possible with VB.

Thanks for any help.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DATE VALIDATION William Excel Discussion (Misc queries) 4 August 7th 08 02:31 PM
date validation LM Excel Worksheet Functions 8 November 1st 07 12:42 AM
Date Validation LM Excel Worksheet Functions 3 October 25th 07 01:59 AM
Date Validation - Must equal Sundays date jeridbohmann Excel Discussion (Misc queries) 14 November 30th 05 08:40 PM
Date validation patam Excel Discussion (Misc queries) 8 September 3rd 05 05:26 PM


All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"