View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
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