magOO Posted March 4, 2004 Posted March 4, 2004 Hello!I have the following Code:For $i1 = 48 To 58 For $i2 = 1 To 8 ... Next NextCan 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 HelpmagOO
ben_josephs Posted March 4, 2004 Posted March 4, 2004 (edited) For $i1 = 48 To 58 For $i2 = 1 To 8 $s = StringFormat ( "%03d, %02d", $i1, $i2 ) MsgBox ( 0, "", $s ) Next Next Edited March 4, 2004 by ben_josephs
Administrators Jon Posted March 4, 2004 Administrators Posted March 4, 2004 StringFormat is great for this stuff. Or you could do it the long way and add a 0 onto the start with $newi = "0" & $i1
magOO Posted March 4, 2004 Author Posted March 4, 2004 Thanks to all for your Help! ben_josephs Solution works great for me!!!
trids Posted March 4, 2004 Posted March 4, 2004 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
scriptkitty Posted March 4, 2004 Posted March 4, 2004 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now