Sign in to follow this  
Followers 0
timmyc

Trying to add 1 onto a value when button is pressed ($input1)+1

4 posts in this topic

Hi All,

This is like GUI 101 so extremely frustrating as i should know how to do this and the help file is not helping me.

I have a button and an input box, Input box is set default to 0.

When button is pressed i want whatever value is in the input box + 1

Its reconnizing the button click but not adding the +1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         case $button1
            $button1 = GUICtrlRead($input1)+1
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Case $Button1
            oneMore()

Func oneMore()
    $theNumber = GUICtrlRead($Input1)
    $theNumber +=1
    GUICtrlSetData($Input1, $theNumber)
EndFunc

I'm pretty sure this is excessive, but easy to understand.

Share this post


Link to post
Share on other sites

 

Hi All,

This is like GUI 101 so extremely frustrating as i should know how to do this and the help file is not helping me.

I have a button and an input box, Input box is set default to 0.

When button is pressed i want whatever value is in the input box + 1

Its reconnizing the button click but not adding the +1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         case $button1
            $button1 = GUICtrlRead($input1)+1
    EndSwitch
WEnd

 

this should fix it:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         case $button1
            GUICtrlSetData($input1,GUICtrlRead($input1)+1)
    EndSwitch
WEnd

What you were doing before was only updating the variable $button1 each time.

To update the input box GUICtrlSetData has to be used :-D

case $button1
            $button1 = GUICtrlRead($input1)+1
case $button1
            GUICtrlSetData($input1,GUICtrlRead($input1)+1)

Share this post


Link to post
Share on other sites

Thanks so much for your help guys.
 

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