Sign in to follow this  
Followers 0
Valuater

how to make the number 01

26 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

lol, this gave me a headache!!


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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)



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

$num = 5

if($num < 10) then $num = "0" & $num


Who else would I be?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

the StringFormat way:

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

$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

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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.

 

Share this post


Link to post
Share on other sites

thanks gafrost.... they both worked great

and thanks for this too..... _SoundGetWaveVolume())

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

yw

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

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

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

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

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

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  
Followers 0