title: Visual Basic Salary tax calculator
body: <p>The process that I'm trying to create is when a user inputs a number it gets detected by the IF statement to display which tax rate it goes under 20%, 40% or 45%, the amount of tax and the salary after for example If 10,000 inputted the tax rate shows 20% of that which calculates the amount of tax "2000" and the salary after tax "8000".These are the calculations I'm trying to workout, "0 to 31,785 tax rate 20%", but "if less than 10,600 tax rate 0%", 31,786 to 150,000 tax rate 40% if less than 42,385 tax rate 0%", over15,000 tax rate 45%.</p>
  
  <p>I have managed to do that for one some IF statement but when I try to do that for the next IF statement the numbers get mixed up and display the wrong results or don't display the tax rate that suppose to show.</p>
  
  <pre><code>Public Class Form1
  
      Private Sub button1_Click(sender As Object, e As EventArgs) Handles cmdCalc.Click
          Dim decSalary, decTax, decTax2, decTax3, decAmount As Decimal
  
          decSalary = textSalary.Text
          decTax = decSalary * 0.2
          decTax2 = decSalary * 0.4
          decTax3 = decSalary * 0.45
          decAmount = decSalary - decTax
  
  
          lblTax.Text = FormatPercent(0.0, 0.2, 0.4, 0.45, TriState.UseDefault)
          Return
          lblAmount.Text = Format(decTax, "currency")
          lblFinal.Text = Format(decAmount, "currency")
  
          If (decSalary &lt;= 10500) Then
              decTax *= 0
          ElseIf (decSalary &gt;= 10600) Then
              decTax *= 0.2
          ElseIf (decSalary &lt;= 31785) Then
              decTax *= 0.2
  
          End If
  
      End Sub
  
      Private Sub textBox1_TextChanged(sender As Object, e As EventArgs) Handles textSalary.TextChanged
          'Dim decSalary, decTax, decTax2, decAmount As Decimal
  
          ' lblTax.Text = FormatPercent(0.0)
          ' lblAmount.Text = Format(decTax, "currency")
          ' lblFinal.Text = Format(decAmount, "currency")
  
          ' If decSalary &lt;= 10500 Then
          'decTax = 0
          ' ElseIf decSalary &gt;= 10600 Then
          ' decTax = 0.2
          '  ElseIf decSalary &lt;= 31785 Then
          '  decTax2 = decTax
  
          '  End If
  
  
  
  
      End Sub
  
      Private Sub Button3_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
          Me.Close()
      End Sub
  
      Private Sub cmdClear_Click(sender As Object, e As EventArgs) Handles cmdClear.Click
          textSalary.Clear()
          lblTax.Text = "0%"
          lblAmount.Text = "0"
          lblFinal.Text = "0"
  
      End Sub
  End Class
  </code></pre>