Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking for valid date

I'm using a userform with a textbox among other things. I
want to ensure that not only does the user submit a date
in that textbox, I want to make sure it is a valid date.
If the date is invalid, I want to display a warning
message.

Thanks for the help.

Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Checking for valid date

Hi Paul

You can use the exit event like this.
It will not leave the textbox untill the textbox is a date

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(TextBox1.Text) Then
MsgBox "not a date"
Cancel = True
End If
End Sub



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



"Paul M." wrote in message ...
I'm using a userform with a textbox among other things. I
want to ensure that not only does the user submit a date
in that textbox, I want to make sure it is a valid date.
If the date is invalid, I want to display a warning
message.

Thanks for the help.

Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Checking for valid date

Look at the Isdate function.

Use the exit event for validating the textbox and also use the event code
for the buttons you are using to close the userform.

--
Regards,
Tom Ogilvy

"Paul M." wrote in message
...
I'm using a userform with a textbox among other things. I
want to ensure that not only does the user submit a date
in that textbox, I want to make sure it is a valid date.
If the date is invalid, I want to display a warning
message.

Thanks for the help.

Paul



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking for valid date

Fantastic !!!...Thanks Ron and Tom, it works like a dream.
-----Original Message-----
Hi Paul

You can use the exit event like this.
It will not leave the textbox untill the textbox is a date

Private Sub TextBox1_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If Not IsDate(TextBox1.Text) Then
MsgBox "not a date"
Cancel = True
End If
End Sub



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



"Paul M." wrote in

message ...
I'm using a userform with a textbox among other things.

I
want to ensure that not only does the user submit a date
in that textbox, I want to make sure it is a valid date.
If the date is invalid, I want to display a warning
message.

Thanks for the help.

Paul



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Checking for valid date

Paul,

Here is one approach

If IsDate(Me.TextBox1.Text) Then
'do your stuff
Else
MsgBox "That's not a date"
Me.TextBox1.SetFocus
End If

Be careful though, dates are riddled with international issues. For
instance, I am in the UK, and if I enter 12/16/2003 which is really invalid,
it treats it as 16/12/2003 and is valid.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul M." wrote in message
...
I'm using a userform with a textbox among other things. I
want to ensure that not only does the user submit a date
in that textbox, I want to make sure it is a valid date.
If the date is invalid, I want to display a warning
message.

Thanks for the help.

Paul



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
checking hyperlinks are valid Rafael Guerreiro Osorio Excel Discussion (Misc queries) 2 April 4th 23 12:57 PM
checking hyperlinks are valid Garbagh Excel Discussion (Misc queries) 2 September 21st 17 05:04 PM
checking hyperlinks are valid Garbagh Excel Discussion (Misc queries) 0 November 30th 06 02:16 PM
checking hyperlinks are valid Rafael Guerreiro Osorio Excel Discussion (Misc queries) 0 November 30th 06 01:34 PM
Checking If Hyperlink Is Valid Steve[_32_] Excel Programming 2 September 14th 03 03:05 AM


All times are GMT +1. The time now is 10:15 AM.

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

About Us

"It's about Microsoft Excel"