This fall, I am taking a Visual Basic class at UNLV as one of the electives for my Masters Degree in Accounting. Projects for the class require application of the concepts learned, but allow for creativity because each student can create whatever design or function for the program he or she desires.
My latest project in this class is a form that estimates an amount of tax based on income, itemized deductions and dependents. It then returns a message to the user in a text box explaining how much tax, if any, is owed. I know the tax code is much more complicated, but for this project, I used a flat 35% tax rate and $3,000 exemption per dependent. The project required simple calculations, using IF statements, and returning a message to the user, so there was no need to go into unnecessary detail.
The first step I took was to create the form, text boxes, and button to run the code. I then wrote the code so that when the “estimate my tax” button is clicked, it calculates the tax, enters the amounts in the text boxes, and returns a message as shown below:
The code to generate the generate the message in the text box is:
If Tax > 0 Then
Message = Name & “, get out your checkbook. You owe “ & Tax & “. “
Message = Name & “, you don’t owe any tax. “
The project works, but it’s a little boring, isn’t it? I decided to have a little bit of fun with the project by adding an additional IF statement:
If Income > 250000 Then
Message = Message & “Wow! You’re making more than $250,000. You’d better hope Congress extends all of the Bush tax cuts! “
When the amount of income entered is greater than $250,000, the message becomes:
I added another IF statement for the number of dependents:
If Dependents > 10 Then
Message = Message & “By the way, you’re not counting your pets as dependents … are you?”
When the number of dependents is more than ten, the message becomes:
This isn’t a useful program since the tax calculation is inaccurate, but I demonstrated the ability to use IF statements and gave my professor a few laughs while he was grading it (hopefully the laughs were worth a few points)!