计算联邦税收预扣税

时间:2016-10-25 01:46:07

标签: visual-studio visual-studio-2012

嘿,我正在努力计算联邦预扣税。我使用Select Case来尝试运行等式。出于某种原因,我无法获得填充到标签中的价值而且有点迷失。任何帮助表示赞赏!

Public Class Form1
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles btnExit.Click
    Me.Close()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnNextEmployee.Click
    txtHourlyWage.Clear()
    txtPreviousYTD.Clear()
    txtWithExem.Clear()
    rdoMarried.Checked = False
    rdoSingle.Checked = False
    txtName.Clear()
    txtHoursWorked.Clear()
    lblEmployeeName.Text = ""
    lblFedTaxInc.Text = ""
    lblFicaTax.Text = ""
    lblGrossEarnings.Text = ""
    lblNetEarnings.Text = ""
    lblUpdatedYTD.Text = ""

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnPayrollSum.Click

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

    'Declare Variables
    Dim decHourlyWage As Decimal 'Hourly Wage
    Dim intHoursWorked As Integer 'Hours worked
    Dim decGrossEarnings As Decimal 'Gross Earnings
    Dim decPreviousYTD As Decimal 'Previous YTD Earnings
    Dim decUpdatedYTD As Decimal 'Updated YTD Earnings
    Dim MedicareTax As Decimal 'Medicare
    Dim SST As Decimal 'Social Security Tax
    Dim SSNDIFF As Decimal 'Difference
    Dim FicaTax As Decimal 'Fica Tax
    Dim decNetEarnings As Decimal 'Net Earnings
    Dim marital As String 'Marital Status
    Dim decFedIncTax As Decimal 'Fed Income tax Withheld
    Dim WithHold As Decimal
    Dim GrossEarnings As Decimal

    'Employee Name
    lblEmployeeName.Text = txtName.Text

    'Calculate and Display Gross Earnings
    decHourlyWage = CDec(txtHourlyWage.Text)
    intHoursWorked = CInt(txtHoursWorked.Text)
    decGrossEarnings = decHourlyWage * intHoursWorked

    'Gross Earnings
    If intHoursWorked < 40 Then
        decGrossEarnings = (decHourlyWage * intHoursWorked)
    ElseIf intHoursWorked > 40 Then
        decGrossEarnings = (40 * decHourlyWage) + ((intHoursWorked - 40) * (decHourlyWage * 1.5))
    End If

    'Withhold
    WithHold = txtWithExem.Text * 55.77

    'Marriage Status
    If Me.rdoSingle.Checked Then
        marital = "S"
    Else
        marital = "M"
    End If

    'GetFWT
    If marital = "S" Then
        Select Case GrossEarnings
            Case decGrossEarnings >= 0 And decGrossEarnings <= 50.99
                decFedIncTax = 0
            Case decGrossEarnings >= 51 And decGrossEarnings <= 500.99
                decFedIncTax = ((decGrossEarnings - 51) - WithHold) * 0.1
            Case decGrossEarnings >= 501 And decGrossEarnings <= 2500.99
                decFedIncTax = (((decGrossEarnings - 501) - WithHold) * 0.15) + 45
            Case 2501 To 5000.99
                decFedIncTax = ((decGrossEarnings - 2501 - WithHold) * 0.2) + 345
            Case decGrossEarnings >= 5001
                decFedIncTax = ((decGrossEarnings - 5001 - WithHold) * 0.25) + 845
        End Select
    Else
        Select Case GrossEarnings
            Case decGrossEarnings = 0 To 50.99
                decFedIncTax = 0
            Case decGrossEarnings = 51 To 500.99
                decFedIncTax = (decGrossEarnings - 51 - WithHold) * 0.05
            Case decGrossEarnings = 501 To 2500.99
                decFedIncTax = ((decGrossEarnings - 501 - WithHold) * 0.1) + 45
            Case decGrossEarnings = 2501 To 5000.99
                decFedIncTax = ((decGrossEarnings - 2501 - WithHold) * 0.15) + 345
            Case decGrossEarnings >= 5001
                decFedIncTax = ((decGrossEarnings - 5001 - WithHold) * 0.2) + 600.5
        End Select
    End If

    'Calculate and Display FICA Tax
    MedicareTax = decGrossEarnings * 0.0145
    If (decPreviousYTD + decGrossEarnings) < 84000 Then
        SST = decGrossEarnings * 0.062
    Else
        If decPreviousYTD > 84000 Then
            SST = 0
        Else
            SSNDIFF = 84000 - decPreviousYTD
            SST = SSNDIFF * 0.062
        End If
    End If
    FicaTax = MedicareTax + SST
    lblFicaTax.Text = FicaTax.ToString("c")

    'Calculate and Display Net Earnings
    decNetEarnings = decGrossEarnings - FicaTax
    lblNetEarnings.Text = decNetEarnings.ToString("c")

    'display Gross earnings
    lblGrossEarnings.Text = decGrossEarnings.ToString("c")

    'display FWT
    lblFedTaxInc.Text = GrossEarnings.ToString("c")

    'Calculate And Display Updated YTD Earnings
    decPreviousYTD = CDec(txtPreviousYTD.Text)
    decUpdatedYTD = decGrossEarnings + decPreviousYTD
    lblUpdatedYTD.Text = decUpdatedYTD.ToString("c")

End Sub

结束班

0 个答案:

没有答案