Jump to content
Sign in to follow this  
Merchants

how to fix a number style

Recommended Posts

Merchants

i want this: 01 + 1 = 02 NOT 2

#include <GUIConstantsEx.au3>
Global $GUI[4]

$GUI[0]= GUICreate("test", 300, 70)
$GUI[1] = GuiCtrlCreateInput("01", 75, 22, 150, 20)
$GUI[2] = GUICtrlCreateButton("+ 1", 230, 21, 50, 22)
GUICtrlCreateLabel("Index 1:", 20, 25)
GUISetState()
While 1
    $GUI[3] = GUIGetMsg($GUI[0])
    Select
        Case $GUI[3] = $GUI_EVENT_CLOSE
            Exit
        Case $GUI[3] = $GUI[2]
            GUICtrlSetData($GUI[1], GUICtrlRead($GUI[1]) + 1)
    EndSelect
WEnd
Edited by Merchants

Share this post


Link to post
Share on other sites
Merchants

StringFormat(). See help file.

:(

wel i have tryed search a stringformat but i can't find it can you help?

Share this post


Link to post
Share on other sites
Malkey

Using StringFormat() :-

GUICtrlSetData($GUI[1], StringFormat ("%02d", GUICtrlRead($GUI[1]) + 1))

or

using StringRight() - 99 maximum number :-

GUICtrlSetData($GUI[1], StringRight("0" & (GUICtrlRead($GUI[1]) + 1),2))

wel i have tryed search a stringformat but i can't find it can you help?

Well, you tried and failed to find the stringformat function in the AutoIt help file. That is unbelievably amazing.

Share this post


Link to post
Share on other sites
99ojo

Hi,

if you want the leading 0 only for numbers < 10:

@edit:

Delete nasty code, use Malkeys....

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites
99ojo

Here is a StringFormat example for you to ponder.

I did now. :)

There was a paste and copy typo error trying your 1st code example, which is absolutly correct.

:(

Stefan

Edited by 99ojo

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.