Jump to content

Format Number


Recommended Posts

Hello!

I have the following Code:

For $i1 = 48 To 58
 For $i2 = 1 To 8
  ...
 Next
Next

Can anbody explain me, how i can convert $i1 to a 3 digit String (Example: 048) and $i2 to a 2 digit String (Example: 01).

Thanks for your Help

magOO

Link to comment
Share on other sites

I know I'm a bit late for the party, but you can also do the following kind of thing ..

For &sNumber = 0 to 1000

       ;Format into 8-digit string..
        $sNumberFmt = StringRight(String(&sNumber + 100000000), 8) 

        FileWriteLine($nFile, $sNumberFmt)   ;or whatever

    Next
Link to comment
Share on other sites

I do this a lot with part numbers, say all part numbers have 4 digits.

QuickExample.

$output=""
for $i=1 to 1200 step 35
$i4=Stringright("0000"&$i,4) ; use the right 4 digits
$output=$output&$i4&@CRLF ; just combining for output
Next
MsgBox(1,"Number",$output)

AutoIt3, the MACGYVER Pocket Knife for computers.

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...