Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    appending a zero

    Hi, I need to know how to append a zero to the front of a number. For example, how to change 6 into 06.
    Thanks
    -Ian

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Delaware, USA
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    iNum = 6;
    paddedNum = "0" + iNum;
    ===============
    Code:
    iNum = 6;
    iPaddedLength = 2;
    paddedNum = ""+iNum;
    while (paddedNum.length < iPaddedLength) {
         paddedNum = "0" + paddedNum;
    }


  •  

    Posting Permissions

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