Sign in to follow this  
Followers 0
farhan879

Calculator --> My version

7 posts in this topic

#1 ·  Posted (edited)

I made a calculator. Its pretty simple and basic and works fine. It may come in handy at times. :P

Source

#cs ----------------------------------------------------------------------------
    
    Pogram  Version: 1.0
    
    Author:         Farhan
    
    Script Function: Calculates maths

    (c) Copyright 2008. All rights reserved.
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=f:\my documents\koda form designer\koda_1.7.0.1\forms\calc.kxf
$Form2 = GUICreate("Calculator", 210, 190, 303, 222)
$Result = GUICtrlCreateInput("", 8, 8, 193, 21)
$clear = GUICtrlCreateButton("Clear", 128, 40, 73, 25, 0)
$One = GUICtrlCreateButton("1", 8, 104, 35, 25, 0)
$Zero = GUICtrlCreateButton("0", 8, 136, 35, 25, 0)
$Point = GUICtrlCreateButton(".", 48, 136, 33, 25, 0)
$Equal = GUICtrlCreateButton("=", 88, 136, 115, 25, 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Two = GUICtrlCreateButton("2", 48, 104, 33, 25, 0)
$Three = GUICtrlCreateButton("3", 88, 104, 33, 25, 0)
$Four = GUICtrlCreateButton("4", 8, 72, 35, 25, 0)
$Five = GUICtrlCreateButton("5", 48, 72, 35, 25, 0)
$Six = GUICtrlCreateButton("6", 88, 72, 35, 25, 0)
$Seven = GUICtrlCreateButton("7", 8, 40, 35, 25, 0)
$Eight = GUICtrlCreateButton("8", 48, 40, 35, 25, 0)
$Nine = GUICtrlCreateButton("9", 88, 40, 35, 25, 0)
$Times = GUICtrlCreateButton("x", 128, 72, 35, 25, 0)
$Plus = GUICtrlCreateButton("+", 128, 104, 33, 25, 0)
$Divide = GUICtrlCreateButton("/", 168, 72, 33, 25, 0)
$Minus = GUICtrlCreateButton("-", 168, 104, 33, 25, 0)
$Menu_file = GUICtrlCreateMenu("&File")
$Menu_about = GUICtrlCreateMenuItem("About", $Menu_file)
$Menu_exit = GUICtrlCreateMenuItem("Exit", $Menu_file)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


GUISetBkColor(0x494e48)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Menu_about
            MsgBox(64, "About", "Product name:   Calculator" & @CRLF & "Author:              Farhan (farhan_879@hotmail.com" & @CRLF & "Version:             1.0" & @CRLF & "" & @CRLF & "(C) Copyright 2008. All rights reserved.")
        Case $Menu_exit
            Exit

        Case $One
            calc(1)

        Case $Two
            calc(2)

        Case $Three
            calc(3)

        Case $Four
            calc(4)

        Case $Five
            calc(5)

        Case $Six
            calc(6)

        Case $Seven
            calc(7)

        Case $Eight
            calc(8)

        Case $Nine
            calc(9)

        Case $Zero
            calc('nul')

        Case $Divide
            calc('/')

        Case $Times
            calc('x')

        Case $Equal
            calc('get')

        Case $Plus
            calc('+')

        Case $Minus
            calc('-')

        Case $Point
            calc('.')

        Case $clear
            GUICtrlSetData($Result, '')

    EndSwitch
WEnd
Func calc($num)
    If $num = 'get' Then
        get()
    Else
        If $num = 'nul' Then
            GUICtrlSetData($Result, GUICtrlRead($Result) & 0)
        Else
            GUICtrlSetData($Result, GUICtrlRead($Result) & $num)
        EndIf

    EndIf
EndFunc   ;==>calc

Func get()
    $p = Execute(StringReplace(GUICtrlRead($Result), 'x', '*'))
    If @error Then
        GUICtrlSetData($Result, 'Syntax ERROR')
    Else
        GUICtrlSetData($Result, $p)
    EndIf

EndFunc   ;==>get

Enjoy :(

Calculator_1.0.zip

Edited by farhan879

System task ---> My first GUICalculator v1.0 ---> My version of the calculatorNetZilla 1.0 --> Web browserEmail Sender --> You can Send emails with this without opening a web browser

Share this post


Link to post
Share on other sites



I made a calculator. Its pretty simple and basic and works fine. It may come in handy at times. :P

Enjoy :(

Calculator_1.0.zip

awesome, you might want to check out my calculator for ideas! i worked really hard on it, and its multilingual :idea: but good work!

global $warming = true

Share this post


Link to post
Share on other sites

Can I ask why you didn't post the source? Seems a bit simple. Source isn't really secret, with something like this.

It does what it say, although simple.


[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

@LimeSeed

Thanks for the positive comment :P I'll be sure i'll check your calculator out! :idea:

@Firestorm

I edited my post :(


System task ---> My first GUICalculator v1.0 ---> My version of the calculatorNetZilla 1.0 --> Web browserEmail Sender --> You can Send emails with this without opening a web browser

Share this post


Link to post
Share on other sites

simple but cool :P


Enjoy the complexity.Feel the power of simplicity.

Share this post


Link to post
Share on other sites

looks nice!..

the _calc function looks a bit like mine: (look at sig for my calc)

(these are the last 50 lines of my code:)

Case $9
            calc(9)
            
        Case $o
            calc('nul')

        Case $deel
            calc('/')

        Case $keer
            calc('x')

        Case $is
            calc('get')

        Case $plus
            calc('+')

        Case $min
            calc('-')

        Case $c
            calc('.')

        Case $clear
            GUICtrlSetData($som, '' )
    EndSwitch
WEnd

func calc($num)
    if $num='get' then
        get()
    Else
        if $num='nul' then
            GUICtrlSetData($som, GUICtrlRead($som)&0)
        Else
            GUICtrlSetData($som, GUICtrlRead($som)&$num)
        EndIf
    EndIf
EndFunc

func get()
    $p = Execute(StringReplace(GUICtrlRead($som), 'x', '*'))
    if @error then
        GUICtrlSetData($som, 'Error' )
    Else
        GUICtrlSetData($som, $p )
    EndIf
EndFunc

:)

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