Closed Thread
Results 1 to 10 of 10

IsDate

  1. #1
    april27
    Guest

    IsDate

    I am writing a macro for an Excel spreadsheet. in a user form i have a text
    field. in this field the user shall enter a date. the program shall then
    revise the date and return an error message if it is not a date. I try to use
    the IsDate function but i dont know how to use it and my help menu does not
    give me any info on this. anyone?

  2. #2
    aidan.heritage@virgin.net
    Guest

    Re: IsDate

    if(not(isdate(TextBoxName.text))) then
    msgbox "You have not entered a valid date - please retry
    cancel=true
    end if

    this would go in the exit event of the text box
    april27 wrote:
    > I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > field. in this field the user shall enter a date. the program shall then
    > revise the date and return an error message if it is not a date. I try to use
    > the IsDate function but i dont know how to use it and my help menu does not
    > give me any info on this. anyone?



  3. #3
    aidan.heritage@virgin.net
    Guest

    Re: IsDate

    if(not(isdate(TextBoxName.text))) then
    msgbox "You have not entered a valid date - please retry
    cancel=true
    end if

    this would go in the exit event of the text box
    april27 wrote:
    > I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > field. in this field the user shall enter a date. the program shall then
    > revise the date and return an error message if it is not a date. I try to use
    > the IsDate function but i dont know how to use it and my help menu does not
    > give me any info on this. anyone?



  4. #4
    aidan.heritage@virgin.net
    Guest

    Re: IsDate

    if(not(isdate(TextBoxName.text))) then
    msgbox "You have not entered a valid date - please retry
    cancel=true
    end if

    this would go in the exit event of the text box
    april27 wrote:
    > I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > field. in this field the user shall enter a date. the program shall then
    > revise the date and return an error message if it is not a date. I try to use
    > the IsDate function but i dont know how to use it and my help menu does not
    > give me any info on this. anyone?



  5. #5
    Norman Jones
    Guest

    Re: IsDate

    Hi Apil27,

    Copied direct from VBA help

    '===================>>:

    IsDate Function

    Returns a Boolean value indicating whether an expression can be converted to
    a date.

    Syntax

    IsDate(expression)

    The required expression argument is a Variant containing a date expression
    or string expression recognizable as a date or time.

    Remarks

    IsDate returns True if the expression is a date or is recognizable as a
    valid date; otherwise, it returns False. In Microsoft Windows, the range of
    valid dates is January 1, 100 A.D. through December 31, 9999 A.D.; the
    ranges vary among operating systems.


    IsDate Function Example
    This example uses the IsDate function to determine if an expression can be
    converted to a date.

    Dim MyDate, YourDate, NoDate, MyCheck
    MyDate = "February 12, 1969": YourDate = #2/12/69#: NoDate = "Hello"
    MyCheck = IsDate(MyDate) ' Returns True.
    MyCheck = IsDate(YourDate) ' Returns True.
    MyCheck = IsDate(NoDate) ' Returns False.

    '<<===================


    ---
    Regards,
    Norman



    "april27" <april27@discussions.microsoft.com> wrote in message
    news:CB41E123-6040-4C5D-81A8-FA0C705808BD@microsoft.com...
    >I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > field. in this field the user shall enter a date. the program shall then
    > revise the date and return an error message if it is not a date. I try to
    > use
    > the IsDate function but i dont know how to use it and my help menu does
    > not
    > give me any info on this. anyone?




  6. #6
    april27
    Guest

    Re: IsDate

    thanks. but what is a valid date? although I type a correct date (i think)
    e.g. 20060612 the program sends me error message. do you know´how to solve
    the problem or write the date in proper form? Very thankful for fast
    assistance!!


    "aidan.heritage@virgin.net" skrev:

    > if(not(isdate(TextBoxName.text))) then
    > msgbox "You have not entered a valid date - please retry
    > cancel=true
    > end if
    >
    > this would go in the exit event of the text box
    > april27 wrote:
    > > I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > > field. in this field the user shall enter a date. the program shall then
    > > revise the date and return an error message if it is not a date. I try to use
    > > the IsDate function but i dont know how to use it and my help menu does not
    > > give me any info on this. anyone?

    >
    >


  7. #7
    Norman Jones
    Guest

    Re: IsDate

    Hi April27,

    >I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > field. in this field the user shall enter a date. the program shall then
    > revise the date and return an error message if it is not a date. I try to
    > use
    > the IsDate function but i dont know how to use it and my help menu does
    > not
    > give me any info on this. anyone?


    Why not use a calendar control for date entry?


    ---
    Regards,
    Norman?



  8. #8
    april27
    Guest

    Re: IsDate

    yes that would be nice but I dont know how to do it. any clue? :-)

    "Norman Jones" skrev:

    > Hi April27,
    >
    > >I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > > field. in this field the user shall enter a date. the program shall then
    > > revise the date and return an error message if it is not a date. I try to
    > > use
    > > the IsDate function but i dont know how to use it and my help menu does
    > > not
    > > give me any info on this. anyone?

    >
    > Why not use a calendar control for date entry?
    >
    >
    > ---
    > Regards,
    > Norman?
    >
    >
    >


  9. #9
    Tom Ogilvy
    Guest

    Re: IsDate

    Excel won't recognize that as a valid date because it can not diffentiate
    that from the number 20,060,612. A good test to see what is accepted as a
    date is to enter it in a cell in the worksheet and see if it is
    displayed/stored as the date you intended.

    If you want to use that format, then you can't use IsDate. You will have to
    write all the code to determine if what is entered is a valid date.

    --
    Regards,
    Tom Ogilvy


    "april27" wrote:

    > thanks. but what is a valid date? although I type a correct date (i think)
    > e.g. 20060612 the program sends me error message. do you know´how to solve
    > the problem or write the date in proper form? Very thankful for fast
    > assistance!!
    >
    >
    > "aidan.heritage@virgin.net" skrev:
    >
    > > if(not(isdate(TextBoxName.text))) then
    > > msgbox "You have not entered a valid date - please retry
    > > cancel=true
    > > end if
    > >
    > > this would go in the exit event of the text box
    > > april27 wrote:
    > > > I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > > > field. in this field the user shall enter a date. the program shall then
    > > > revise the date and return an error message if it is not a date. I try to use
    > > > the IsDate function but i dont know how to use it and my help menu does not
    > > > give me any info on this. anyone?

    > >
    > >


  10. #10
    Tom Ogilvy
    Guest

    Re: IsDate

    http://www.rondebruin.nl/calendar.htm

    --
    Regards,
    Tom Ogilvy


    "april27" wrote:

    > yes that would be nice but I dont know how to do it. any clue? :-)
    >
    > "Norman Jones" skrev:
    >
    > > Hi April27,
    > >
    > > >I am writing a macro for an Excel spreadsheet. in a user form i have a text
    > > > field. in this field the user shall enter a date. the program shall then
    > > > revise the date and return an error message if it is not a date. I try to
    > > > use
    > > > the IsDate function but i dont know how to use it and my help menu does
    > > > not
    > > > give me any info on this. anyone?

    > >
    > > Why not use a calendar control for date entry?
    > >
    > >
    > > ---
    > > Regards,
    > > Norman?
    > >
    > >
    > >


Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1