I have to create an app that computes the amount income tax that a person has to pay, depending on salary. Income tax should be calculated for each portion of income in each range. Here are the following income ranges and taxe rates:
Not over $7825=10%income tax
$7825-31852 = 15%income tax
$31851-77100 = 25%income tax
$77101-160850 =28%income tax
$160850-349700=33%income tax
Over $349700 =35%income tax
Here is the code so far:

Public Class IncomeTaxForm

Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
    Dim IncomeTax As Double = 0
    Dim salary As Double = 0

    Select Case IncomeTax
    Case Is <= 7825
    taxResultLabel.Text = (salary * 0.1)

    Case 7826 To 31850
    taxResultLabel.Text = ((salary - 7826) * 0.15)

    Case 31851 To 77100
    taxResultLabel.Text = ((salary - 31851) * 0.25)

    Case 77101 To 160850
    taxResultLabel.Text = ((salary - 77101) * 0.28)

    Case 160850 To 349700
    taxResultLabel.Text = ((salary - 160850) * 0.33)

    Case Is > 349700
    taxResultLabel.Text = ((salary - 349700) * 0.35)

    End Select

    taxResultLabel.Text = String.Format("{0:C}", salary)

I keep getting zeros. Do i have to add another equation for each case?

Recommended Answers

All 3 Replies

Member Avatar for Unhnd_Exception

Everything you have is fine.

Problem is salary is:

Dim salary As Double = 0

Set the salary before entering the select block and remove the last line because your setting it in the select block.

Your never setting the salary. Its 0.


'
Adding More on Edit
'

Dim SalaryToComputeIncomeTaxOn As Double = 45500

        Select Case SalaryToComputeIncomeTaxOn
            Case Is <= 7825
                SalaryToComputeIncomeTaxOn *= 0.1

            Case 7826 To 31850
                SalaryToComputeIncomeTaxOn *= 0.15

            Case 31851 To 77100
                SalaryToComputeIncomeTaxOn *= 0.25

            Case 77101 To 160850
                SalaryToComputeIncomeTaxOn *= 0.28

            Case 160850 To 349700
                SalaryToComputeIncomeTaxOn *= 0.33

            Case Is > 349700
                SalaryToComputeIncomeTaxOn *= 0.35

        End Select

        LabelTotalIncomeTax.Text = String.Format("{0:C}", SalaryToComputeIncomeTaxOn)

ok i appreciate this, but now when i try this i keep getting the same number which is the salary that has been declared.So no matter what number i enter in the salarytextbox. This is what i want to enter, 25000 in the salarytextbox and in the taxresulttextbox it should give me $3,358.75

i got it thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.