+ Reply to Thread
Results 1 to 8 of 8

padding out zeros in textbox

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    padding out zeros in textbox

    Hello,

    I have a userform with textboxes. One of the textboxes must be a string with 12 characters long (numeric). If the user only inputs 4 digits then I want the textbox to automatically fill the rest of the string with zeros (I want the zeros to be padded out to the left so the numeric digits go to the right)

    Does anyone know what code I could use to make this happen and where the code would go? (ie textbox, command button etc)

    Thankyou!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: padding out zeros in textbox

    Seems to be a duplicate post. Isn't it?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: padding out zeros in textbox

    No I dont think so

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: padding out zeros in textbox

    Ok... Then try like this...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: padding out zeros in textbox

    Thankyou again! It works but i need the total string to be 12 characters long, eg if the user puts 1111 then there would be 8 zeros padded out. At the moment if the user inputs 4 digits then it is giving a further 12 zeros....any ideas?

    Thankyou

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: padding out zeros in textbox

    Try this…

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: padding out zeros in textbox

    Thats brilliant thankyou so much again

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: padding out zeros in textbox

    Glad it helps you and thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Textbox will not display trailing zeros
    By jcaskey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2013, 07:48 AM
  2. Padding the end of each row
    By smfernando in forum Excel General
    Replies: 0
    Last Post: 04-03-2008, 10:27 AM
  3. padding ?
    By vbastarter in forum Excel General
    Replies: 2
    Last Post: 03-07-2006, 08:11 AM
  4. [SOLVED] Removing textbox padding, how to please, Excel 2000/2003
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2005, 08:15 PM
  5. Autofit Padding
    By saskin23 in forum Excel General
    Replies: 0
    Last Post: 03-02-2005, 11:33 AM

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