LimeSeed Posted August 25, 2008 Posted August 25, 2008 Here is a calculator, because i searched the forum and not enough were written. I tried to write this as efficiently as possible and make it easy to understand so here! Hope ya like it let me know of any improvements! expandcollapse popup#NoTrayIcon #include <guiconstants.au3> #include <EditConstants.au3> ;calculator created by isaac flaum Guicreate("Calc", 105, 130) $i = 0 $input = GUICtrlCreateInput("", 5, 5, 95, 20, $ES_READONLY) $7 = guictrlcreatebutton("7", 5, 30, 20, 20) $8 = guictrlcreatebutton("8", 30, 30, 20, 20) $9 = guictrlcreatebutton("9", 55, 30, 20, 20) $4 = guictrlcreatebutton("4", 5, 55, 20, 20) $5 = guictrlcreatebutton("5", 30, 55, 20, 20) $6 = guictrlcreatebutton("6", 55, 55, 20, 20) $1 = guictrlcreatebutton("1", 5, 80, 20, 20) $2 = guictrlcreatebutton("2", 30, 80, 20, 20) $3 = guictrlcreatebutton("3", 55, 80, 20, 20) $equals = guictrlcreatebutton("=", 5, 105, 20, 20) $0 = guictrlcreatebutton("0", 30, 105, 20, 20) $operation = 4 ;0 = plus, 1 = minus, 2 = times, 3 = divide, 4 = nothing $clear = guictrlcreatebutton("C", 55, 105, 20, 20) $divide = guictrlcreatebutton("/", 80, 30, 20, 20) $multiply = guictrlcreatebutton("x", 80, 55, 20, 20) $plus = guictrlcreatebutton("+", 80, 80, 20, 20) $minus = guictrlcreatebutton("-", 80, 105, 20, 20) guisetstate(@SW_SHOW) Do $msg = guigetmsg() if ($msg = -3) Then $i = 1 EndIf Select Case($msg = $0) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "0") Case($msg = $1) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "1") Case($msg = $2) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "2") Case($msg = $3) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "3") Case($msg = $4) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "4") Case($msg = $5) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "5") Case($msg = $6) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "6") Case($msg = $7) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "7") Case($msg = $8) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "8") Case($msg = $9) $pnum = guictrlread($input) guictrlsetdata($input, $pnum & "9") Case ($msg = $plus) $num1 = guictrlread($input) $operation = 0 guictrlsetdata($input, "") Case ($msg = $minus) $num1 = guictrlread($input) $operation = 1 guictrlsetdata($input, "") Case ($msg = $multiply) $num1 = guictrlread($input) $operation = 2 guictrlsetdata($input, "") Case ($msg = $divide) $num1 = guictrlread($input) $operation = 3 guictrlsetdata($input, "") Case ($msg = $equals) if $operation = 0 Then _add() Elseif $operation = 1 Then _subtract() Elseif $operation = 2 Then _multiply() Elseif $operation = 3 Then _divide() Else EndIf $operation = 4 Case ($msg = $clear) $num1 = 0 $num2 = 0 guictrlsetdata($input, "") EndSelect Until $i = 1 func _add() $num2 = guictrlread($input) $final = $num1 + $num2 guictrlsetdata($input, $final) EndFunc func _subtract() $num2 = guictrlread($input) $final = $num1 - $num2 guictrlsetdata($input, $final) EndFunc func _multiply() $num2 = guictrlread($input) $final = ($num1 * $num2) guictrlsetdata($input, $final) EndFunc func _divide() $num2 = guictrlread($input) $final = ($num1 / $num2) guictrlsetdata($input, $final) EndFunc global $warming = true
gseller Posted August 26, 2008 Posted August 26, 2008 Bravo, Very Nice!! The first one I think I have seen on here that does not show the calculation like 25*3=75..I like it! Thanks for sharing...
Amerigo Posted August 28, 2008 Posted August 28, 2008 It's works great and looks good. I just have to use a magnifing glass. Just kidding, but it is kinda tiny. That is better than my LCARS calculator which is a full screen app. Anyone who does not wonder is either omniscient or foolish.
rasim Posted August 28, 2008 Posted August 28, 2008 (edited) LimeSeedHa-ha! Very easy and nice! Edited August 28, 2008 by rasim
LimeSeed Posted August 28, 2008 Author Posted August 28, 2008 Thanks :-) now i will add more functions! sorry it is so small, i just like my gui's small and organized! global $warming = true
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