Sign in to follow this  
Followers 0
z0mgItsJohn

Simple Calculator v 1.0

6 posts in this topic

Well... Heres My Newest Script :) Its A Calculator ^^ Well.. Here Ya Go ^^

#Include <GUIConstants.au3>
#include <Sound.au3>
#NoTrayIcon
Opt('GUIOnEventMode',1)

$GUI = GUICreate(" Simple Calculator v 1.0", 315, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
$Menu = GUICtrlCreateMenu ( "Options" )
$Item_1 = GUICtrlCreateMenuItem ( "Clear Fields", $Menu )
GUICtrlSetOnEvent ($Item_1, "_Clear_All")
$Item_2 = GUICtrlCreateMenuItem ( "Play Song", $Menu )
GUICtrlSetOnEvent ($Item_2, "_Play_Song")
$Item_3 = GUICtrlCreateMenuItem ( "Stop Song", $Menu )
GUICtrlSetOnEvent ($Item_3, "_Stop_Song")
$Item_4 = GUICtrlCreateMenuItem ( "Exit", $Menu )
GUICtrlSetOnEvent ($Item_4, "_Exit")
$Add_1 = GUICtrlCreateInput("", 25, 32, 65, 20)
GUICtrlCreateLabel ( "+",104,33)
$Add_2 = GUICtrlCreateInput("", 125, 32, 65, 20)
$_Add_Equal = GUICtrlCreateInput("", 225, 32, 65, 20)
$_Add_Equal_Button = GUICtrlCreateButton ( "=",198,32,20,19)
GUICtrlSetTip ($_Add_Equal_Button, "Add Equal Button")
GUICtrlSetOnEvent ($_Add_Equal_Button, "_Add")
$Subtract_1 = GUICtrlCreateInput("", 25, 75, 65, 20)
GUICtrlCreateLabel ( "",104,78)
$Subtract_2 = GUICtrlCreateInput("", 125, 75, 65, 20)
$_Subtract_Equal = GUICtrlCreateInput("", 225, 75, 65, 20)
$_Subtract_Equal_Button = GUICtrlCreateButton ( "=",198,75,20,19)
GUICtrlSetOnEvent ($_Subtract_Equal_Button, "_Subtract")
GUICtrlSetTip ($_Subtract_Equal_Button, "Subtract Equal Button")
$Multiply_1 = GUICtrlCreateInput("", 25, 118, 65, 20)
GUICtrlCreateLabel ( "×",104,120)
$Multiply_2 = GUICtrlCreateInput("", 125, 118, 65, 20)
$_Multiply_Equal = GUICtrlCreateInput("", 225, 118, 65, 20)
$_Multiply_Equal_Button = GUICtrlCreateButton ( "=",198,118,20,19)
GUICtrlSetTip ($_Multiply_Equal_Button, "Multiply Equal Button")
GUICtrlSetOnEvent ($_Multiply_Equal_Button, "_Multiply")
$Divide_1 = GUICtrlCreateInput("", 25, 161, 65, 20)
GUICtrlCreateLabel ( "÷",104,163)
$Divide_2 = GUICtrlCreateInput("", 125, 161, 65, 20)
$_Divide_Equal = GUICtrlCreateInput("", 225, 161, 65, 20)
$_Divide_Equal_Button = GUICtrlCreateButton ( "=",198,161,20,19)
GUICtrlSetOnEvent ($_Divide_Equal_Button, "_Divide")
GUICtrlSetTip ($_Divide_Equal_Button, "Divide Equal Button")
GUISetState (@SW_SHOW)

While 1
Sleep (250)
WEnd

Func _Add ()                            
$Add_Equal = GUICtrlRead($Add_1) + GUICtrlRead($Add_2)
GUICtrlSetData ($_Add_Equal, $Add_Equal)
EndFunc    

Func _Subtract ()
$Subtract_Equal = GUICtrlRead($Subtract_1) - GUICtrlRead($Subtract_2)
GUICtrlSetData ($_Subtract_Equal, $Subtract_Equal)
EndFunc

Func _Multiply ()
$Multiply_Equal = GUICtrlRead($Multiply_1) * GUICtrlRead($Multiply_2)
GUICtrlSetData ($_Multiply_Equal, $Multiply_Equal)
EndFunc 

Func _Divide ()
$Divide_Equal = GUICtrlRead($Divide_1) / GUICtrlRead($Divide_2)
GUICtrlSetData ($_Divide_Equal, $Divide_Equal)
EndFunc 

Func _Clear_All ()
GUICtrlSetData ($Add_1, "")
GUICtrlSetData ($Add_2, "")
GUICtrlSetData ($_Add_Equal, "")
GUICtrlSetData ($Subtract_1, "")
GUICtrlSetData ($Subtract_2, "")
GUICtrlSetData ($_Subtract_Equal, "")
GUICtrlSetData ($Multiply_1, "")
GUICtrlSetData ($Multiply_2, "")
GUICtrlSetData ($_Multiply_Equal, "")
GUICtrlSetData ($Divide_1, "")
GUICtrlSetData ($Divide_2, "")
GUICtrlSetData ($_Divide_Equal, "")
EndFunc

Func _Play_Song ()
_SoundPlay ( "Song.mp3" )
EndFunc

Func _Stop_Song ()
_SoundClose ( "Song.mp3" )
EndFunc

Func _Exit ()
Exit
EndFunc

Please Report Bugs.. Comments Ect. ;D


Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

asdf + afalkelk = 0

I think you may want to change the style of your input boxes..

They should have the $ES_NUMBER style take a look at how this is:

$Add_2 = GUICtrlCreateInput("", 125, 32, 65, 20, $ES_NUMBER)

Do that for all the input boxes and that will be one thing fixed!

EDIT: Play and Stop the song, seem unneed but never the less they do not work.

Edited by DBak

[center][/center]

Share this post


Link to post
Share on other sites

Why would you want your calculator to play music? Its pointless.

Share this post


Link to post
Share on other sites

lol.. a music playing calculator :)

thats the first time ive seen that on theese forums


Mads3n.dk

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