Jump to content
Sign in to follow this  
Marlo

Enumerate numbers from 01 to 09

Recommended Posts

Marlo

Helloooooooooo, it's been a while since I coded anything in AutoIt but today I came across a use for it.

Anyway I just need to know if there's anyway I can get AutoIt to enumerate numbers from 01 to 09 instead of 1 to 9.

For example:

For $I = 01 To 50
    ;the first 9 numbers I want prefixed with a 0 and and from there just count normally so...
    ;01, 02, 03, 04, 05, 06, 07, 07, 08, 09, 10, 11, ..., 49, 50
    ;I want to do this because I will be working with strings.
Next

I know how I could work around it by manually adding the 0 for the first nine I'm hoping there's a cleaner way.

Kind regards

~Marlo

Edited by Marlo

Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites
Yoriz

Local $sString
For $I = 1 To 50
    ;the first 9 numbers I want prefixed with a 0 and and from there just count normally so...
    ;01, 02, 03, 04, 05, 06, 07, 07, 08, 09, 10, 11, ..., 49, 50
    ;I want to do this because I will be working with strings.
    $sString &= StringFormat("%02s", $I) & ","
Next
ConsoleWrite(StringTrimRight($sString,1) & @CR)


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites
duzers

hello,

How I do this with GUICtrlCreateInput and GUICtrlCreateUpdown?

thx

Share this post


Link to post
Share on other sites
duzers

Read the control with GuiCtrlRead() and then pass the value to StringFormat() as above.

:idea:

Yes, but I can autochange Input with fix number when I click UP/DOWN.

Share this post


Link to post
Share on other sites
PsaltyDS

You would have to read the contents of the Input control attached to the UpDown, apply the formatting to it, then write back to the input. You can't set it to do that (leading zeroes) without intervention:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $input, $updown, $msg, $sData

GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)

$input = GUICtrlCreateInput("2", 10, 10, 100, 20)
$updown = GUICtrlCreateUpdown($input)
GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case Else
            If $sData <> GUICtrlRead($input) Then
                $sData = GUICtrlRead($input)
                $sData = StringFormat("%03d", $sData)
                GUICtrlSetData($input, $sData)
            EndIf
    EndSwitch
WEnd

MsgBox(0, "Updown", GUICtrlRead($input))

:idea:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.