Sign in to follow this  
Followers 0
Skrip

Simple Calculator!

4 posts in this topic

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")
    $answerm = $var1 * $var2
    MsgBox(0, "Answer", $answerm)
    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")
    $answerd = $var3 / $var4
    MsgBox(0, "Answer", $answerd)
    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")
    $answers = $var5 - $var6
    MsgBox(0, "Answer", $answers)
    Case $msg = $Button_4;Add
    $var7 = InputBox("Add", "Please Enter FIRST NUMBER in equasion", "3")
    $Var8 = InputBox("Add", "Please Enter SECOND NUMBER in equasion", "3")
    $answera = $var7 + $var8
    MsgBox(0, "Answer", $answera)
    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 this post


Link to post
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 this post


Link to post
Share on other sites

Update Version 1.5

Added Area and Proportion

#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")
    $answerm = $var1 * $var2
    MsgBox(0, "Answer", $answerm)
    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")
    $answerd = $var3 / $var4
    MsgBox(0, "Answer", $answerd)
    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")
    $answers = $var5 - $var6
    MsgBox(0, "Answer", $answers)
    Case $msg = $Button_4;Add
    $var7 = InputBox("Add", "Please Enter FIRST NUMBER in equasion", "3")
    $Var8 = InputBox("Add", "Please Enter SECOND NUMBER in equasion", "3")
    $answera = $var7 + $var8
    MsgBox(0, "Answer", $answera)
    Case $msg = $button_5;Area
    $var9 = InputBox("Area", "Please Enter the LEGNTH", "3")
    $Var10 = InputBox("Area", "Please Enter WIDTH", "3")
    $answerarea = $var9 + $Var10
    MsgBox(0, "Answer", "The area is " & $answerarea)
    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]

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