Jump to content

Wages Calculator


dufran3
 Share

Recommended Posts

Was estimating my wages today, and was annoyed by having to multiply my standard hours x standard rate + overtime hours x overtime rate = total...minus taxes, lol...:)

; Paycheck Calculator

#include <GUIConstantsEx.au3>


Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID, $SubmitID, $iStdHours, $iStdRate, $iOtHours, $iOtRate, $iweeks, $vEstPay

_Main()

Func _Main()
    ;Local

    GUICreate("Wages Calculator", 250, 200)

    ; INPUT
    GuiCtrlCreateLabel('Standard Hours',10,1)
    $iStdHours = GuiCtrlCreateInput('0', 10, 15, 100, 20)
    GuiCtrlCreateLabel('Rate of Pay',130,1)
    $iStdRate = GuiCtrlCreateInput('0', 130, 15, 70, 20)
    GuiCtrlCreateLabel('Overtime Hours',10,40)
    $iOtHours = GuiCtrlCreateInput('0', 10, 54, 100, 20)
    GuiCtrlCreateLabel('Rate of Pay',130,40)
    $iOtRate = GuiCtrlCreateInput('0', 130, 54, 70, 20)
    $iweeks = GUICtrlCreateInput('0', 10, 135, 20, 20)
    GUICtrlCreateLabel('# of weeks', 35, 137)
    GUICtrlCreateLabel('Estimated Pay',125, 100)
    $vEstPay = GUICtrlCreateInput('', 125, 114, 70, 20, 0x0800)
    $ExitID = GUICtrlCreateButton("Exit", 180, 175, 50, 20)
    $SubmitID = GUICtrlCreateButton('Calculate', 125, 175, 50, 20)
    GUICtrlSetOnEvent($ExitID, "OnExit")
    GUICtrlSetOnEvent($SubmitID, 'onsubmit')

    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

    GUISetState()  ; display the GUI

    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main

;--------------- Functions ---------------
Func onsubmit()
    Local $vStdHours,$vStdRate,$vStdPay,$vOtHours,$vOtRate,$vOtPay,$vTotalPay,$vWeeks,$vAdjTotalPay
    
    $vStdHours = GuiCtrlRead($istdHours)
    If $vStdHours <> 0 Then
        $vStdRate = GuiCtrlRead($iStdRate)
        If $vStdRate <> 0 Then
            $vStdPay = $vStdHours * $vStdRate
        EndIf
    EndIf
        
    $vOtHours = GuiCtrlRead($iOtHours)
    If $vOtHours <> 0 Then
        $vOtRate = GuiCtrlRead($iOtRate)
        If $vOtRate <> 0 Then
            $vOtPay = $vOtHours * $vOtRate
        EndIf
    EndIf
    
    $vTotalPay = $vStdPay + $vOtPay
    GUICtrlSetData($vEstPay, '$' & $vTotalPay)
    
    $vWeeks = GuiCtrlRead($iWeeks)
    If $vWeeks <> 0 Then
        $vAdjTotalPay = $vTotalPay * $vWeeks
        GUICtrlSetData($vEstPay, '$' & $vAdjTotalPay)
    EndIf
    
EndFunc
Func OnExit()
    Exit
EndFunc   ;==>OnExit
Edited by dufran3
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...