home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmPayroll
- Caption = "Weekly Payroll"
- ClientHeight = 3120
- ClientLeft = 1170
- ClientTop = 2145
- ClientWidth = 7740
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3120
- ScaleWidth = 7740
- Begin VB.CommandButton cmdNext
- Caption = "Next Employee"
- Height = 495
- Left = 3000
- TabIndex = 13
- Top = 2520
- Width = 2175
- End
- Begin VB.PictureBox picResults
- Height = 2295
- Left = 4080
- ScaleHeight = 2235
- ScaleWidth = 3435
- TabIndex = 15
- Top = 120
- Width = 3495
- End
- Begin VB.TextBox txtPriorPay
- Height = 285
- Left = 2640
- TabIndex = 11
- Top = 1920
- Width = 1215
- End
- Begin VB.TextBox txtMarital
- Height = 285
- Left = 2640
- TabIndex = 9
- Top = 1560
- Width = 1215
- End
- Begin VB.TextBox txtExempts
- Height = 285
- Left = 2640
- TabIndex = 7
- Top = 1200
- Width = 1215
- End
- Begin VB.TextBox txtHours
- Height = 285
- Left = 2640
- TabIndex = 5
- Top = 840
- Width = 1215
- End
- Begin VB.TextBox txtWage
- Height = 285
- Left = 2640
- TabIndex = 3
- Top = 480
- Width = 1215
- End
- Begin VB.TextBox txtName
- Height = 285
- Left = 2640
- TabIndex = 1
- Top = 120
- Width = 1215
- End
- Begin VB.CommandButton cmdQuit
- Caption = "Quit"
- Height = 495
- Left = 5640
- TabIndex = 14
- Top = 2520
- Width = 1455
- End
- Begin VB.CommandButton cmdDisplay
- Caption = "Display Payroll"
- Height = 495
- Left = 360
- TabIndex = 12
- Top = 2520
- Width = 2175
- End
- Begin VB.Label lblPriorPay
- Alignment = 1 'Right Justify
- Caption = "Total Pay Prior to this Week:"
- Height = 255
- Left = 0
- TabIndex = 10
- Top = 1920
- Width = 2535
- End
- Begin VB.Label lblMarital
- Alignment = 1 'Right Justify
- Caption = "Marital Status (M or S):"
- Height = 255
- Left = 480
- TabIndex = 8
- Top = 1560
- Width = 2055
- End
- Begin VB.Label lblExempts
- Alignment = 1 'Right Justify
- Caption = "Number of Exemptions:"
- Height = 255
- Left = 480
- TabIndex = 6
- Top = 1200
- Width = 2055
- End
- Begin VB.Label lblHours
- Alignment = 1 'Right Justify
- Caption = "Number of Hours Worked:"
- Height = 255
- Left = 240
- TabIndex = 4
- Top = 840
- Width = 2295
- End
- Begin VB.Label lblWage
- Alignment = 1 'Right Justify
- Caption = "Hourly Wage:"
- Height = 255
- Left = 1320
- TabIndex = 2
- Top = 480
- Width = 1215
- End
- Begin VB.Label lblName
- Alignment = 1 'Right Justify
- Caption = "Employee Name:"
- Height = 255
- Left = 1080
- TabIndex = 0
- Top = 120
- Width = 1455
- End
- Attribute VB_Name = "frmPayroll"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- 'Program to compute employees' weekly payroll
- Private Sub cmdDisplay_Click()
- Dim empName As String 'Name of employee
- Dim hrWage As Single 'Hourly wage
- Dim hrsWorked As Single 'Hours worked this week
- Dim exemptions As Integer 'Number of exemptions for employee
- Dim mStatus As String 'Marital status: S for Single; M for Married
- Dim prevPay As Single 'Total pay for year excluding this week
- Dim pay As Single 'This week's pay before taxes
- Dim totalPay As Single 'Total pay for year including this week
- Dim ficaTax As Single 'FICA taxes for this week
- Dim fedTax As Single 'Federal income tax withheld this week
- Dim check As Single 'Paycheck this week (take-home pay)
- 'Obtain data, compute payroll, display results
- Call InputData(empName, hrWage, hrsWorked, exemptions, mStatus, prevPay) 'Task 0
- pay = Gross_Pay(hrWage, hrsWorked) 'Task 1
- totalPay = Total_Pay(prevPay, pay) 'Task 2
- ficaTax = FICA_Tax(pay, prevPay, totalPay) 'Task 3
- fedTax = Fed_Tax(pay, exemptions, mStatus) 'Task 4
- check = Net_Check(pay, ficaTax, fedTax) 'Task 5
- Call ShowPayroll(empName, pay, totalPay, ficaTax, fedTax, check) 'Task 6
- End Sub
- Private Sub cmdNext_Click()
- 'Clear all text boxes for next employee's data
- txtName.Text = " "
- txtWage.Text = " "
- txtHours.Text = " "
- txtExempts.Text = " "
- txtMarital.Text = " "
- txtPriorPay.Text = " "
- picResults.Cls
- End Sub
- Private Sub cmdQuit_Click()
- End
- End Sub
- Private Function Fed_Tax(pay As Single, exemptions As Integer, mStatus As String)
- Dim adjPay As Single
- 'Task 4.1: Compute federal income tax
- adjPay = pay - (51.92 * exemptions)
- If adjPay < 0 Then
- adjPay = 0
- End If
- If mStatus = "S" Then
- Fed_Tax = TaxSingle(adjPay) 'Task 4.2
- Else
- Fed_Tax = TaxMarried(adjPay) 'Task 4.3
- End If
- Fed_Tax = Round(Fed_Tax, 2) 'Round to nearest cent
- End Function
- Private Function FICA_Tax(pay As Single, prevPay As Single, totalPay As Single)
- Dim socialSecurity As Single 'Social Security tax for this week
- Dim medicare As Single 'Medicare tax for this week
- 'Task 3: Compute Social Security and Medicare tax
- If totalPay <= 68400 Then
- socialSecurity = 0.062 * pay
- ElseIf prevPay < 68400 Then
- socialSecurity = 0.062 * (68400 - prevPay)
- End If
- medicare = 0.0145 * pay
- FICA_Tax = socialSecurity + medicare
- FICA_Tax = Round(FICA_Tax, 2) 'Round to nearest cent
- End Function
- Private Function Gross_Pay(hrWage As Single, hrsWorked As Single)
- 'Task 1: Compute weekly pay before taxes
- If hrsWorked <= 40 Then
- Gross_Pay = hrsWorked * hrWage
- Else
- Gross_Pay = 40 * hrWage + (hrsWorked - 40) * 1.5 * hrWage
- End If
- End Function
- Private Sub InputData(empName As String, hrWage As Single, _
- hrsWorked As Single, exemptions As Integer, _
- mStatus As String, prevPay As Single)
- 'Get payroll data for employee
- empName = txtName.Text
- hrWage = Val(txtWage.Text)
- hrsWorked = Val(txtHours.Text)
- exemptions = Val(txtExempts.Text)
- mStatus = Left(UCase(txtMarital.Text), 1) 'M or S
- prevPay = Val(txtPriorPay.Text)
- End Sub
- Private Function Net_Check(pay As Single, ficaTax As Single, fedTax As Single)
- 'Task 5: Compute amount of money given to employee
- Net_Check = pay - ficaTax - fedTax
- End Function
- Private Sub ShowPayroll(empName As String, pay As Single, _
- totalPay As Single, ficaTax As Single, fedTax As Single, check As Single)
- 'Display results of payroll computations
- picResults.Cls
- picResults.Print "Payroll results for "; empName
- picResults.Print
- picResults.Print " Gross pay this period: "; FormatCurrency(pay)
- picResults.Print
- picResults.Print " Year-to-date earnings: "; FormatCurrency(totalPay)
- picResults.Print
- picResults.Print " Fica Taxes this period: "; FormatCurrency(ficaTax)
- picResults.Print
- picResults.Print " Income tax withheld: "; FormatCurrency(fedTax)
- picResults.Print
- picResults.Print "Net pay (check amount): "; FormatCurrency(check)
- End Sub
- Private Function TaxMarried(adjPay As Single) As Single
- 'Task 6.3: Compute federal tax for married person based on adjusted pay
- Select Case adjPay
- Case 0 To 124
- TaxMarried = 0
- Case 124 To 899
- TaxMarried = 0.15 * (adjPay - 124)
- Case 899 To 1855
- TaxMarried = 116.25 + 0.28 * (adjPay - 899)
- Case 1855 To 3084
- TaxMarried = 383.93 + 0.31 * (adjPay - 1855)
- Case 3084 To 5439
- TaxMarried = 764.92 + 0.36 * (adjPay - 3084)
- Case Is > 5439
- TaxMarried = 1612.72 + 0.396 * (adjPay - 5439)
- End Select
- End Function
- Private Function TaxSingle(adjPay As Single) As Single
- 'Task 6.2: Compute federal tax for single person based on adjusted pay
- Select Case adjPay
- Case 0 To 51
- TaxSingle = 0
- Case 51 To 517
- TaxSingle = 0.15 * (adjPay - 51)
- Case 517 To 1105
- TaxSingle = 69.6 + 0.28 * (adjPay - 517)
- Case 1105 To 2493
- TaxSingle = 234.54 + 0.31 * (adjPay - 1105)
- Case 2493 To 5385
- TaxSingle = 664.82 + 0.36 * (adjPay - 2493)
- Case Is > 5385
- TaxSingle = 1705.94 + 0.396 * (adjPay - 5385)
- End Select
- End Function
- Private Function Total_Pay(prevPay As Single, pay As Single)
- 'Compute total pay before taxes
- Total_Pay = prevPay + pay
- End Function
- Private Sub picResults_Click()
- End Sub
-