Sign in to follow this  
Followers 0
magOO

Format Number

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

For $i1 = 48 To 58
  For $i2 = 1 To 8
    $s = StringFormat ( "%03d, %02d", $i1, $i2 )
    MsgBox ( 0, "", $s )
  Next
Next

Edited by ben_josephs

Share this post


Link to post
Share on other sites

Thanks to all for your Help! :whistle:

ben_josephs Solution works great for me!!!

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0