Whenever you have a series of decisions like this, a Select Case structure ought to be considered. Here's the same code using a Select Case Structure:
~~~~~~~~~~~~~~~~~~~~~~~~~
Select Case AdjustedIncome
Case Is <= 27050 ' 15% tax bracket
TaxDue = AdjustedIncome * 0.15
Case Is <= 65550 ' 28% tax bracket
TaxDue = 4057.5 + ((AdjustedIncome - 27050) * 0.28)
Case Is <= 136750 ' 31% tax bracket
TaxDue = 4057.5 + ((AdjustedIncome - 65550) * 0.31)
Case Is <= 297350 ' 36% tax bracket
TaxDue = 4057.5 + ((AdjustedIncome - 136750) * 0.36)
Case Else ' 39.6% tax bracket
TaxDue = 4057.5 + ((AdjustedIncome - 297350) * 0.396)
End Select
~~~~~~~~~~~~~~~~~~~~~~~~~
If you initialize AdjustedIncome to say, $1,000,000 (that is, a small, insignificant fraction of what Bill Gates makes in a year), you will find that you get exactly the same answer with either code. Use MsgBox or Debug.Write to see the answer. (If you use Debug.Write, make sure the Output window is displayed.
So ...
Assignment: Which One Should You Use?
I'll give you MY answer in the next lesson! But remember, your answer might be just as good as mine. Leave a message in the About Visual Basic Forum and tell us what YOUR answer is.
Microsoft has a complete explanation of how to read their syntax diagrams at their MSDN page.


