+ Reply to Thread
Results 1 to 2 of 2

Empty a textbox when selecting it

  1. #1
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Empty a textbox when selecting it

    Hello everybody.
    I have this userform with two textboxes.
    I've added this code so that the user nows what to enter:
    If TextBox1.Value = Empty Then TextBox1 = "dd-mm-yyyy"
    Also I've added this code Cancelbtn.SetFocus so that the textbox is not selected when you load the form.

    My first question is when you select that textbox, regardless where the mouse clicks, the text disappears and you can enter your text.

    Also when you're entering the date after you've entered de dd the "-" comes up automatically and the after the mm it does the same thing.

    Many thanks,

    Pedro

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    This code will clear the textbox as soon as you click in it:
    Please Login or Register  to view this content.
    As far as modifying the entry into a date format, there is no "simple" way of doing it. You actually have to write code to make the change. For example:

    Please Login or Register  to view this content.
    Obviously, you will have to modify that code based on your format. Also, there should be checks to make sure that the number entered is in fact a number, and maybe error handling in case someone enters in a different amount of numbers (ie, 012207 = 01/22/07 vs 12207 = 1/22/07

+ 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