Jump to content

how to make the number 01


Valuater
 Share

Recommended Posts

I have this

$updown3 = GUICtrlCreateUpdown($T_Min, $UDS_HORZ + $UDS_ARROWKEYS)
GUICtrlSetLimit ( $updown3, 10, 1)

problem is it represents the numbers as

1

2

3

4

5

6

7

8

9

10

i need the numbers to be

01

02

03

04

05

06

07

08

09

10

couldn't find the needed info.... any help is appreciated

EDIT

OR... maybe i can set it as 01 then update the control ????

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

If you converted your numbers to strings and somehow counted the characters in the string you could add a 0 at the front of any with just one charactar (ie 1-9)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

I have this

$updown3 = GUICtrlCreateUpdown($T_Min, $UDS_HORZ + $UDS_ARROWKEYS)
GUICtrlSetLimit ( $updown3, 10, 1)

problem is it represents the numbers as

1

2

3

4

5

6

7

8

9

10

i need the numbers to be

01

02

03

04

05

06

07

08

09

10

couldn't find the needed info.... any help is appreciated

EDIT

OR... maybe i can set it as 01 then update the control ????

8)

Here is the code you need:

CODE
#include "GUIConstants.au3"

$title = "!"

GUICreate($title,-1,-1,-1,-1, $WS_SIZEBOX)

$input = GUICtrlCreateInput ("01",10,10, 50, 20)

$updown = GUICtrlCreateUpdown($input)

GUICtrlSetLimit ( $updown, 10, 1)

GUISetState ()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

If $msg = $updown Then

$d = GUICtrlRead($input)

If ($d <= 9) And ($d >= 2) Then

$d = "0" & $d

GUICtrlSetData ( $input, $d)

ElseIf $d = 1 Then

$d = "01"

GUICtrlSetData ( $input, $d)

EndIf

EndIf

WEnd

Link to comment
Share on other sites

  • Developers

Does StringFormat help? You may need to convert your numeric values to strings.

the StringFormat way:

$a=StringFormat("%02d",$a)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

$a = 1

$a = StringRight("0" & $a,2)

MsgBox(4096,"",$a)

;Lar.

That works ok for two characters, my solution will work even if the numbers are expanded upon later.

The string format function looks interesting, I'll have to play with it a bit.

Ok. String format is very nice except look at this bug..

CODE

#include "GUIConstants.au3"

$title = "!"

GUICreate($title,-1,-1,-1,-1, $WS_SIZEBOX)

$input = GUICtrlCreateInput ("01",10,10, 50, 20)

$updown = GUICtrlCreateUpdown($input)

GUICtrlSetLimit ( $updown, 1000, 1)

GUISetState ()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

If $msg = $updown Then

$txt = GUICtrlRead($input)

$a=StringFormat("%02d",$txt)

GUICtrlSetData ( $input, $a)

EndIf

WEnd

When you reach 1,000 and click up it will go back to 01. If you don't use StringFormat this will not happen. Fix please. ;)

Edited by ligenza
Link to comment
Share on other sites

CODE

#include "GUIConstants.au3"

$title = "!"

GUICreate($title, -1, -1, -1, -1, $WS_SIZEBOX)

$input = GUICtrlCreateInput("01", 10, 10, 50, 20)

$updown = GUICtrlCreateUpdown($input)

GUICtrlSetLimit($updown, 1000, 1)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

If $msg = $updown Then GUICtrlSetData($input, StringFormat("%02d",StringReplace(GUICtrlRead($input),",","")))

WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

thank you... thank you ALL

for your effort

i am going to try all of the ideas.... but my favorite line is from mr wizzard with

If $msg = $updown3 Then GUICtrlSetData($T_Min, StringFormat("%02d",StringReplace(GUICtrlRead($T_Min),",","")))

which includes JdeB's $a=StringFormat("%02d",$a)

ok..... i had found my answer late last night by the "Hobbyiest" way... like this

If $msg = $updown3 Then
        $Min_set = GUICtrlRead($T_Min)
        If $Min_set = 1 then GUICtrlSetData($T_Min, "01")
        If $Min_set = 2 then GUICtrlSetData($T_Min, "02")
        If $Min_set = 3 then GUICtrlSetData($T_Min, "03")
        If $Min_set = 4 then GUICtrlSetData($T_Min, "04")
        If $Min_set = 5 then GUICtrlSetData($T_Min, "05")
        If $Min_set = 6 then GUICtrlSetData($T_Min, "06")
        If $Min_set = 7 then GUICtrlSetData($T_Min, "07")
        If $Min_set = 8 then GUICtrlSetData($T_Min, "08")
        If $Min_set = 9 then GUICtrlSetData($T_Min, "09")
        
    EndIf

simple... clean... but lots of lines

thnaks again

NEWHeader1.png

Link to comment
Share on other sites

sorry haven't used the updown before so didn't know about this style, so here's another solution also:

CODE

#include "GUIConstants.au3"

$title = "!"

GUICreate($title, -1, -1, -1, -1, $WS_SIZEBOX)

$input = GUICtrlCreateInput("01", 10, 10, 50, 20)

$updown = GUICtrlCreateUpdown($input,$UDS_NOTHOUSANDS)

GUICtrlSetLimit($updown, 1000, 1)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

If $msg = $updown Then GUICtrlSetData($input, StringFormat("%02d",GUICtrlRead($input)))

WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Care to comment about the 1,000 glitch? Didn't think so. ;)

Lay off gafrost he helps lots of people on this forum.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

not a glitch, updown control defaults to using the thousands seperator.

Your amazing ability to not comprehend what is said astounds me! The glitch I was refering to is that once at 1,000 when you incriment the value it goes to 01 and it does not do that when you don't use the format string function. I'm awaiting the fix for it. :P

Lay off gafrost he helps lots of people on this forum.

That implys that I don't which is hardly the case unlike you however. ;) The "solution" here gay provided was merly a more refined version of what I had posted not to discredit him though, just using this as an example of why you're an idiot. Also, you idiot, if you look at gays code it's a direct copy and paste of mine with edits.. to imply I did nothing is very cruel of you. I'll be the first to admit however that the code gafrost posted here is superior to what I posted and him basing it off my little code snippit is of no consequence. Let it be said though that they are indeed just that, code snippits so they are not valid to draw assumptions from. I want to help people obtain solutions that work well. Edited by ligenza
Link to comment
Share on other sites

That implys that I don't which is hardly the case unlike you however. ;) The "solution" here gay provided was merly a more refined version of what I had posted not to discredit him though, just using this as an example of why you're an idiot. Also, you idiot, if you look at gays code it's a direct copy and paste of mine with edits.. to imply I did nothing is very cruel of you. I'll be the first to admit however that the code gafrost posted here is superior to what I posted and him basing it off my little code snippit is of no consequence. Let it be said though that they are indeed just that, code snippits so they are not valid to draw assumptions from. I want to help people obtain solutions that work well.

I never implied that you did nothing and it is not nice to call someone an idiot just cause they can't program as good as you.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Stringformat

kma

You fixed it! Thanks.

$UDS_NOTHOUSANDS was what differed.

I never implied that you did nothing and it is not nice to call someone an idiot just cause they can't program as good as you.

Oh but it's fun and a valid retort to your comment. I didn't just say you were an idiot though I made it very clear exactly why I thought that. ;) Edited by ligenza
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...