Jump to content

how to make the number 01


Valuater
 Share

Recommended Posts

Here's the one that pads as many zeros in front of a number that you want. I call it "Procrustes". Enjoy!

$pad = "0"
$procrustes = InputBox("How long?","How long do you want your digits?",2)
$a = InputBox("Enter a number:","Enter the number you want to convert","1")

for $i = 1 to $procrustes - stringlen($a)
    $pad = $pad & "0"
next
$a = StringRight($pad & $a,$procrustes)

MsgBox(4096,"",$a)

OR, this version has one less line:

#include <string.au3>
$pad = "0"
$procrustes = InputBox("How long?","How long do you want your digits?",2)
$a = InputBox("Enter a number:","Enter the number you want to convert","1")

$pad = _StringRepeat("0",$procrustes - stringlen($a))
$a = StringRight($pad & $a,$procrustes)

MsgBox(4096,"",$a)
Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Here's the one that pads as many zeros in front of a number that you want. I call it "Procrustes". Enjoy!

$pad = "0"
$procrustes = InputBox("How long?","How long do you want your digits?",2)
$a = InputBox("Enter a number:","Enter the number you want to convert","1")

for $i = 1 to $procrustes - stringlen($a)
    $pad = $pad & "0"
next
$a = StringRight($pad & $a,$procrustes)

MsgBox(4096,"",$a)
I like it. ;)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...