# Wages Calculator

## 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()

If \$vStdHours <> 0 Then
If \$vStdRate <> 0 Then
\$vStdPay = \$vStdHours * \$vStdRate
EndIf
EndIf

If \$vOtHours <> 0 Then
If \$vOtRate <> 0 Then
\$vOtPay = \$vOtHours * \$vOtRate
EndIf
EndIf

\$vTotalPay = \$vStdPay + \$vOtPay
GUICtrlSetData(\$vEstPay, '\$' & \$vTotalPay)

If \$vWeeks <> 0 Then
EndIf

EndFunc
Func OnExit()
Exit
EndFunc   ;==>OnExit```
Edited by dufran3

## Create an account

Register a new account

×

• Wiki

• Back

• Git