View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel[_77_] joel[_77_] is offline
external usenet poster
 
Posts: 1
Default Text Box Dates in Userform?


Textboxes are strings and not dates. You must convert the string to
dates and check the date. Use Datevalue to convert from string to Date

the string can be in any valide date format
MyDate = DateValue("February 12, 1969")

You can use ISDate() function to validate that the string is a valid
date.

You mayu also want to add a check to make sure the date is withing a
valid range

do
GoodDate = False
MyDate = Texbox1.value
if IsDate(MyDate) then
'check if date is within valid dates
SDate = DateValue(MyDate)
if SDate = DateValue("1/1/2000") and _
SDate = DateValue("12/31/2010") then

GoodDate = True
end if
end if
loop while GoodDate = False


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=147400