Jump to content

Recommended Posts

Posted

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
Posted

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.

Posted

 

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)

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
×
×
  • Create New...