Jump to content

how to fix a number style


Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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