Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Visual Basic 2010 federal tax calculator?

It's a calculator that shows the federal tax due.

"Write a program that obtains taxable income, calculates the federal income tax, and outputs the amount of tax due. Use a Sub Procedure to read the taxable income, a Function Procedure to calculate the federal income tax, and a Sub Procedure to output the federal income tax. You MUST use the following code for your “Compute Tax” Button Click Procedure.

Dim income, tax As Double

'Obtain Taxable Income

GetTaxableIncome(income)

' Calculate Federal Tax

tax = CalculateFederalTax(income)

' Output Federal Tax

DisplayFederalTax(tax)

"

This is what I have so far and I cannot for the life of me get it to work. It will not show the results in the federal tax text box.

Please help, I am losing my mind....

Function calculatefederaltax(ByVal income As Double) As Double

Select Case income

Case Is < 0

Return 0

Case Is < 8700

Return 0.1 * income

Case Is < 35350

Return 870 + (0.15 * (income - 8700))

Case Is < 85650

Return 4867.5 + (0.25 * (income - 35350))

Case Is < 178650

Return 17442.5 + (0.28 * (income - 85650))

Case Is < 388350

Return 43482.5 + (0.33 * (income - 178650))

Case Else

Return 112683.5 + (0.35 * (income - 388350))

End Select

End Function

Sub Displayfederaltax(ByVal tax As Double)

txtIncome.Text = FormatCurrency(tax, 2)

End Sub

5 Answers

Relevance
  • 8 years ago
    Favorite Answer

    The following code works.

    It must be the same as shown, do not revise it, as did one Asker of a similar question.

    There is a button and 2 text boxes. Enter the taxable income in txtIncome before you click the button.

    Public Class Form1

    Public income, tax As Double

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

    'Obtain Taxable Income

    income = GetTaxableIncome(income)

    ' Calculate Federal Tax

    tax = calculatefederaltax(income)

    ' Output Federal Tax

    Displayfederaltax(tax)

    End Sub

    Function calculatefederaltax(ByVal income As Double) As Double

    Dim tax As Double

    Select Case income

    Case Is < 0

    tax = 0

    Case Is < 8700

    tax = 0.1 * income

    Case Is < 35350

    tax = 870 + (0.15 * (income - 8700))

    Case Is < 85650

    tax = 4867.5 + (0.25 * (income - 35350))

    Case Is < 178650

    tax = 17442.5 + (0.28 * (income - 85650))

    Case Is < 388350

    tax = 43482.5 + (0.33 * (income - 178650))

    Case Else

    tax = 112683.5 + (0.35 * (income - 388350))

    End Select

    Return tax

    End Function

    Sub Displayfederaltax(ByVal tax As Double)

    txtTax.Text = FormatCurrency(tax, 2)

    End Sub

    Function GetTaxableIncome(income)

    income = Val(txtIncome.Text)

    Return income

    End Function

    End Class

    EDIT

    I did not include the code to validate the input to txtIncome was a numeric value, I had to develop it last night.

    Place the following code in the txtIncome KeyPress event. This will not allow you to enter anuthing but numbers, "." and control keys.

    Private Sub txtIncome_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtIncome.KeyPress

    Dim c As Char = e.KeyChar

    If Not (Char.IsDigit(c) Or c = "." Or Char.IsControl(c)) Then

    e.Handled = True

    End If

    End Sub

    @Claire

    I never submit an answer with code, unless I have coded it and debugged it. There is obviously something else wrong in your coding.

    I edited my answer to show a code thet allos only numbers, a period and controls keys to be recognized when you press a key to enter something in your text box that returns the taxable income.

    I will send you my regular email address so you can send me your entire code, if you want me to debug it. However, you must allow me to email you through YA email.

    Did you see the corrections I made to another asker's code (you answered his question about a tax application)

    TexMav

  • ihde
    Lv 4
    5 years ago

    2010 Tax Calculator

  • Anonymous
    7 years ago

    Hi jonathan I've read about that, Try the link below http://taxinstantfaqs.net/?k=20130210151453AAAkCwT for me it was perfect Good Luck,

  • Anonymous
    8 years ago

    Does your teacher have office hours? Do you know the smart kid? This kinds of questions are not really going to get much of an answer here!

  • How do you think about the answers? You can sign in to vote the answer.
  • 8 years ago

    @Texas - I edited your code to fit the parameters of my assignment. We aren't using flags yet. And no, it didn't work perfectly in my design, even with the flags.

Still have questions? Get your answers by asking now.