+ Reply to Thread
Results 1 to 2 of 2

Textbox Date formatting problem

  1. #1
    Capp
    Guest

    Textbox Date formatting problem

    I am a new user so the answer may be very simple. I have looked through the
    various threads and haven't found this problem.

    I have created a userform with a textbox for inputting a date. However,
    when I launch the form and start entering the date it defaults to some wrong
    date and will not allow me to enter the correct date. This seems pretty
    strait forward but I cant seem to get my date input field to work properly.
    Any suggestions?

    This is the code I am using.

    Private Sub Tb_Date_Change()

    Tb_Date.Value = Format(Date,"dd-mmm-yyyy")

    End Sub





  2. #2
    Ron de Bruin
    Guest

    Re: Textbox Date formatting problem

    Hi Capp

    Use the exit event like this
    It will run when you leave the textbox

    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox1.Value = Format(TextBox1.Value, "dd-mmm-yyyy")
    End Sub

    Why don't you use a calendar control
    you not have to test then if the date is a real date that you enter in the textbox
    http://www.rondebruin.nl/calendar.htm

    See the userform example on this link that is on that page
    http://www.fontstuff.com/vba/vbatut07.htm


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Capp" <[email protected]> wrote in message news:[email protected]...
    >I am a new user so the answer may be very simple. I have looked through the
    > various threads and haven't found this problem.
    >
    > I have created a userform with a textbox for inputting a date. However,
    > when I launch the form and start entering the date it defaults to some wrong
    > date and will not allow me to enter the correct date. This seems pretty
    > strait forward but I cant seem to get my date input field to work properly.
    > Any suggestions?
    >
    > This is the code I am using.
    >
    > Private Sub Tb_Date_Change()
    >
    > Tb_Date.Value = Format(Date,"dd-mmm-yyyy")
    >
    > End Sub
    >
    >
    >
    >




+ Reply to 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