Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
'declare variables and constants
Const conLanctax As Double = 0.01
Const conFica As Double = 0.062
Const conMedi As Double = 0.0125
Const conpatax As Double = 0.0307
Dim decnetpay As Decimal
Dim decOver As Decimal
Dim decweek1 As Decimal
Dim decweek2 As Decimal
Dim decrate As Decimal
Dim declanctax As Decimal
Dim decpatax As Decimal
Dim decfica As Decimal
Dim decmedi As Decimal
Dim decfed As Decimal
Dim decotrate As Decimal
Dim decotpay As Decimal
Dim decgross As Decimal
Dim decover2 As Decimal
Dim decotpay2 As Decimal
Dim decbenefits As Decimal
Dim decpay As Decimal
Dim strStatus As String
'determine if the information entered is numeric
If IsNumeric(txtweek1.Text) Then
decweek1 = Val(txtweek1.Text)
Else
MsgBox("Please enter a number in the box", MsgBoxStyle.Critical, "Number Required")
End If
If IsNumeric(txtweek2.Text) Then
decweek2 = Val(txtweek2.Text)
Else
MsgBox("Please enter a number in the box", MsgBoxStyle.Critical, "Number Required")
End If
If IsNumeric(txtRate.Text) Then
decrate = Val(txtRate.Text)
Else
MsgBox("Please enter a number in the box", MsgBoxStyle.Critical, "Number required")
End If
If IsNumeric(txtbenefits.Text) Then
decbenefits = Val(txtbenefits.Text)
Else
MsgBox("Please enter a number in the box", MsgBoxStyle.Critical, "Number Required")
End If
'determine if overtime will be calculated
If decweek1 > 40 Then
decOver = decweek1 - 40
decotrate = decrate * 1.5
decotpay = decOver * decotrate
End If
If decweek2 > 40 Then
decover2 = decweek2 - 40
decotrate = decrate * 1.5
decotpay2 = decOver * decotrate
End If
'Calculate the gross pay and determine taxes
decpay = (decrate * ((decweek1 - decOver) + (decweek2 - decover2))) + (decotpay + decotpay2)
decgross = decpay - decbenefits
lblgross.Text = FormatCurrency(decpay, 2)
declanctax = decgross * conLanctax
lblLanc.Text = FormatCurrency(declanctax, 2)
decpatax = decgross * conpatax
lblPA.Text = FormatCurrency(decpatax, 2)
decfica = decgross * conFica
lblFica.Text = FormatCurrency(decfica, 2)
decmedi = decgross * conMedi
lblMedi.Text = FormatCurrency(decmedi, 2)
strStatus = cboStatus.Text
Select Case strStatus
Case Is = "Single"
Select Case decgross
Case Is < 290.38
decfed = decgross * 0.1
Case Is < 1178.84
decfed = ((decgross - 290.38) * 0.15) + 29.04
Case Is < 2853.84
decfed = ((decgross - 1178.84) * 0.25) + 162.3
Case Is < 5953.68
decfed = ((decgross - 2853.84) * 0.28) + 581.06
Case Is < 12944.23
decfed = ((decgross - 5953.68) * 0.33) + 1437.14
Case Is > 12944.23
decfed = ((decgross - 12942.3) * 0.35) + 3755.88
End Select
Case Is = "Married"
Select Case decgross
Case Is < 580.76
decfed = decgross * 0.1
Case Is < 2357.69
decfed = ((decgross - 580.76) * 0.15) + 58.08
Case Is < 4757.69
decfed = ((decgross - 2357.69) * 0.25) + 324.62
Case Is < 7248.08
decfed = ((decgross - 4757.69) * 0.28) + 924.62
Case Is < 12944.23
decfed = ((decgross - 7248.08) * 0.33) + 1621.92
Case Is > 12944.23
decfed = ((decgross - 12944.23) * 0.35) + 3501.65
End Select
Case Is = "Seperated"
Select Case decgross
Case Is < 290.38
decfed = decgross * 0.1
Case Is < 1178.84
decfed = ((decgross - 290.38) * 0.15) + 29.04
Case Is < 2378.85
decfed = ((decgross - 1178.84) * 0.25) + 162.3
Case Is < 3624.04
decfed = ((decgross - 2378.85) * 0.28) + 462.31
Case Is < 6472.12
decfed = ((decgross - 3624.04) * 0.33) + 810.96
Case Is > 6472.12
decfed = ((decgross - 6472.12) * 0.35) + 1750.83
End Select
Case Is = "Head of Household"
Select Case decgross
Case Is < 413.46
decfed = decgross * 0.1
Case Is < 1578.85
decfed = ((decgross - 413.46) * 0.15) + 41.35
Case Is < 4076.92
decfed = ((decgross - 1578.85) * 0.25) + 216.15
Case Is < 6601.92
decfed = ((decgross - 4076.92) * 0.28) + 840.67
Case Is < 12944.23
decfed = ((decgross - 6601.92) * 0.33) + 1547.67
Case Is > 12944.23
decfed = ((decgross - 12944.23) * 0.35) + 3640.63
End Select
End Select
decnetpay = decgross - declanctax - decpatax - decfica - decmedi - decfed
lblFed.Text = FormatCurrency(decfed, 2)
lblPay.Text = FormatCurrency(decnetpay, 2)
End Sub
Wednesday, April 28, 2010
calculate Income Tax using vb.net
1:28 AM
Unknown
0 comments:
Post a Comment