Sign in to follow this  
Followers 0
teamdad

Button Help

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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()

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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... :whistle:

Share this post


Link to post
Share on other sites

#6 ·  Posted (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... :whistle:

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 by jpm

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