+ Reply to Thread
Results 1 to 3 of 3

Adding leading zeros to a text box

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Adding leading zeros to a text box

    Hi there,

    I have a user form, with a text box for the user to input a purchase order number.
    I would like to have the user type in a 3-digit number (001, 010, 100), but have
    the entry displayed as FB-2013-001, or FB-2013-010, or FB-2013-100.

    what is the code to have the 'FB-2013-' part of the display be automatic and not
    have the user type all that in.

    As I have it now, the leading zeros don't show, so I get FB-2013-1, or FB-2013-10.

    Any and all help is appreciated.

    frank

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Adding leading zeros to a text box

    Hello fbiasi,

    The prefix can be added automatically using the TextBox_AfterUpdate() event. This event is fired when the user presses the Enter key or clicks on another control. Change TextBox1 to match your TextBox's name.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Adding leading zeros to a text box

    Hi Leith,

    Thanks for the response.
    I just tried the code and still the result doesn't show the leading zeros in the cell that is bound to the textbox.

    Here is the code:

    Please Login or Register  to view this content.

+ 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