Public Class frmFICA

  Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
    'Calculate social security benefits tax and Medicare tax
    'for a single pay period in 2009
    Const WAGE_BASE As Double = 106800   'There is no social security benefits
    '                                     tax on income above this level
    Dim ytdEarnings, curEarnings As Double
    Dim socialSecurityBenTax, medicareTax, ficaTaxes As Double
    ytdEarnings = CDbl(txtToDate.Text)
    curEarnings = CDbl(txtCurrent.Text)
    If (ytdEarnings + curEarnings) <= WAGE_BASE Then
      socialSecurityBenTax = 0.062 * curEarnings
    ElseIf ytdEarnings < WAGE_BASE Then
      socialSecurityBenTax = 0.062 * (WAGE_BASE - ytdEarnings)
    End If
    medicareTax = 0.0145 * curEarnings
    ficaTaxes = socialSecurityBenTax + medicareTax
    txtTax.Text = FormatCurrency(ficaTaxes)
  End Sub

End Class
