teamdad Posted April 1, 2004 Share Posted April 1, 2004 With the code below how can I get the button to do the calculations for the math? GUICreate("My balance GUI") $startbalance = GuiSetControl ("input", "", 10, 10, 50) $payment = GuiSetControl ("input", "", 70, 10, 50) $deposit = GuiSetControl ("input", "", 130, 10, 50) $balance = GuiSetControl ("Label", "0", 195, 10, 50) $n=GuiRead($startbalance)-GuiRead($payment)+GuiRead($deposit) GuiSetControl("button","OK",10,50,50) GuiWrite($balance, 0, $n) GUIWaitClose() I must not be good at reading or something. Every snippet of code I try from the help file just causes the button to close the program when I click on it. I think the rest of the code will work fine but I need a method of doing the math when the button is clicked. Much thanks in advance Link to comment Share on other sites More sharing options...
Josbe Posted April 1, 2004 Share Posted April 1, 2004 Add GuiSetControlNotify()GuiSetControl("button","OK",10,50,50) GuiSetControlNotify() AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
teamdad Posted April 1, 2004 Author Share Posted April 1, 2004 Even with adding the suggested code it just closes the gui completely. GUICreate("My balance GUI") $startbalance = GuiSetControl ("input", "", 10, 10, 50) $payment = GuiSetControl ("input", "", 70, 10, 50) $deposit = GuiSetControl ("input", "", 130, 10, 50) $balance = GuiSetControl ("Label", "0", 195, 10, 50) $n=GuiRead($startbalance)-GuiRead($payment)+GuiRead($deposit) GuiSetControl("button","OK",10,50,50) GuiSetControlNotify() GUIWaitClose() Link to comment Share on other sites More sharing options...
teamdad Posted April 1, 2004 Author Share Posted April 1, 2004 I got the button to work -for keeping the gui open with this code: GuiSetControlNotify() but it doesn't do the math I want it to do. I want it to take the $startbalance subtract the $payment and add the $deposit then put the answer in the label at the end. Any suggestions? Link to comment Share on other sites More sharing options...
Josbe Posted April 1, 2004 Share Posted April 1, 2004 Sorry, I forget...While$tit= "My balance GUI" GUICreate($tit) $startbalance = GuiSetControl ("input", "", 10, 10, 50) $payment = GuiSetControl ("input", "", 70, 10, 50) $deposit = GuiSetControl ("input", "", 130, 10, 50) $balance = GuiSetControl ("Label", "0", 195, 10, 50) GuiSetControl("button","OK",10,50,50) GuiSetControlNotify() While GuiMsg () >0 $n=GuiRead($startbalance)-GuiRead($payment)+GuiRead($deposit) ControlSetText($tit, "", "Static1", $n) Wendtry this... AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
jpm Posted April 1, 2004 Share Posted April 1, 2004 (edited) Sorry, I forget...While $tit= "My balance GUI" GUICreate($tit) $startbalance = GuiSetControl ("input", "", 10, 10, 50) $payment = GuiSetControl ("input", "", 70, 10, 50) $deposit = GuiSetControl ("input", "", 130, 10, 50) $balance = GuiSetControl ("Label", "0", 195, 10, 50) GuiSetControl("button","OK",10,50,50) GuiSetControlNotify() While GuiMsg () >0 $n=GuiRead($startbalance)-GuiRead($payment)+GuiRead($deposit) ControlSetText($tit, "", "Static1", $n) Wend try this... GuiWrite will do the same as the ControlSetText GUICreate("My balance GUI") $startbalance = GuiSetControl ("input", "0", 10, 10, 50) GuiSetControlEx(-1,256) GuiSetControl("label","-",65,10,10,20) $payment = GuiSetControl ("input", "0", 70, 10, 50) GuiSetControl("label","+",125,10,10,20) $deposit = GuiSetControl ("input", "0", 130, 10, 50) GuiSetControl("label","=",185,10,-1,20) $balance = GuiSetControl ("Label", "0", 195, 10, 50) ;($balance - $payment) + $deposit = $balance While GuiMsg()>0 $n=GuiRead($startbalance)-GuiRead($payment)+GuiRead($deposit) GuiWrite($balance,0,$n) Wend Edited April 1, 2004 by jpm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now