# Simple Calculator!

## Recommended Posts

I got bored so I thought i'd see if I could make a calculator!

```#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global \$WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 167, 58,(@DesktopWidth-167)/2, (@DesktopHeight-58)/2 , \$WS_OVERLAPPEDWINDOW + \$WS_VISIBLE + \$WS_CLIPSIBLINGS)

\$Button_1 = GuiCtrlCreateButton("Multiply", 0, 0, 90, 30)
\$Button_2 = GuiCtrlCreateButton("Divide", 90, 0, 80, 30)
\$Button_3 = GuiCtrlCreateButton("Subtract", 0, 30, 90, 30)
\$Button_4 = GuiCtrlCreateButton("Add", 90, 30, 80, 30)
\$var = 0
GuiSetState()
While 1
\$msg = GuiGetMsg()
Select
Case \$msg = \$GUI_EVENT_CLOSE
ExitLoop
Case \$msg = \$Button_1;Multiply
\$var1 = InputBox("Multiply", "Please Enter FIRST NUMBER in equasion", "3")
\$Var2 = InputBox("Multiply", "Please Enter SECOND NUMBER in equasion", "3")
Case \$msg = \$Button_2;Divide
\$var3 = InputBox("Divide", "Please Enter FIRST NUMBER in equasion", "3")
\$Var4 = InputBox("Divide", "Please Enter SECOND NUMBER in equasion", "3")
Case \$msg = \$Button_3;Subtract
\$var5 = InputBox("Subtract", "Please Enter FIRST NUMBER in equasion", "3")
\$Var6 = InputBox("Subtract", "Please Enter SECOND NUMBER in equasion", "3")
EndSelect
WEnd
Exit```

Simple but it works!

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

##### Share on other sites

Maybe I will, but I am WAY away from that old code, I've made extensions and newer codes, control panels, and 'QA' (Quick-activate) program(s). Like you press a button and a gui pops up. Stuff like that.

I'll post them when i'm done.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

##### Share on other sites

Update Version 1.5

```#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global \$WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Calculator", 170, 90,(@DesktopWidth-167)/2, (@DesktopHeight-58)/2 , \$WS_OVERLAPPEDWINDOW + \$WS_VISIBLE + \$WS_CLIPSIBLINGS)

\$Button_1 = GuiCtrlCreateButton("Multiply", 0, 0, 90, 30)
\$Button_2 = GuiCtrlCreateButton("Divide", 90, 0, 80, 30)
\$Button_3 = GuiCtrlCreateButton("Subtract", 0, 30, 90, 30)
\$Button_4 = GuiCtrlCreateButton("Add", 90, 30, 80, 30)
\$button_5 = GUICtrlCreateButton("Area", 0, 60, 90, 30)
\$button_6 = GUICtrlCreateButton("Proportion", 90, 60,  80, 30)
\$var = 0
GuiSetState()
While 1
\$msg = GuiGetMsg()
Select
Case \$msg = \$GUI_EVENT_CLOSE
ExitLoop
Case \$msg = \$Button_1;Multiply
\$var1 = InputBox("Multiply", "Please Enter FIRST NUMBER in equasion", "3")
\$Var2 = InputBox("Multiply", "Please Enter SECOND NUMBER in equasion", "3")
Case \$msg = \$Button_2;Divide
\$var3 = InputBox("Divide", "Please Enter FIRST NUMBER in equasion", "3")
\$Var4 = InputBox("Divide", "Please Enter SECOND NUMBER in equasion", "3")
Case \$msg = \$Button_3;Subtract
\$var5 = InputBox("Subtract", "Please Enter FIRST NUMBER in equasion", "3")
\$Var6 = InputBox("Subtract", "Please Enter SECOND NUMBER in equasion", "3")
Case \$msg = \$button_5;Area
\$var9 = InputBox("Area", "Please Enter the LEGNTH", "3")
\$Var10 = InputBox("Area", "Please Enter WIDTH", "3")
Case \$msg = \$button_6;Proportion
\$var11 = InputBox("Proportion ~~ A", "Please Enter A", "3")
\$Var12 = InputBox("Proportion ~~ B", "Please Enter B", "3")
\$Var13 = InputBox("Proportion ~~ C", "Please Enter C", "3")
\$answerpro = \$var11 * \$Var12 / \$Var13
MsgBox(0, "Answer", \$var11 & " * " & \$Var12 & " / " & \$Var13 & " = " & \$answerpro )
EndSelect
WEnd
Exit```

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

## Create an account

Register a new account