# New to VB and struggling with assignment

• ### Question

• By no means do I expect someone to provide me the answer, but a nudge in the right direction would help. So I'm new to programming and struggling with an assignment from my online college. I'll provide my code so far, and the problem assigned to us. I have asked the teacher for help and he has responded, but I'm still just not understanding it. I really hate to trot in here and throw out a homework question, but I'm unsure what else to do.

Problem

"Novelty Warehouse needs an application that allows the user to enter an item's price. When the user clicks a button in the interface, the button's Click event procedure should add the price to the total of the prices already entered; this amount represents the subtotal owed by the customer. The application should display the subtotal on the screen. It should also display a 3% sales tax, the shipping charge, and the total due from the customer. The total due is calculated by adding together the subtotal, the 3% sales tax, and a \$15 shipping charge. For example, if the user enters 26.75 as the price and then clicks the button, the button's Click event procedure should display 26.75 as the subtotal, 0.80 as the sales tax, 15.00 as the shipping charge, and 42.55 as the total due. If the user subsequently enters 30 as the price and then clicks the button, the button's Click event procedure should display 56.75 as the subtotal, 1.70 as the sales tax, 15.00 as the shipping charge, and 73.45 as the total due. However, when the subtotal is at least 100, the shipping charge is 0 (zero). You can either create your own user interface or create the one shown in Figure 4-49 on page 227 of the textbook. Click the Exit button and then close the solution. Zip the project folder into a single zip file and submit it to the form inside this folder."

My Code so far:

Dim ship As Double
Dim totaldue As Double
Dim subtotal As Double
Dim tax As Double

Double.TryParse(itemPriceTextBox.Text, subtotal)

If subtotal > 100 Then
ship = 0
Else
ship = 15

End If

tax = 0.03 * subtotal
itemPriceTextBox.Text = (subtotal)
subtotalLabel.Text = (subtotal)
salesTaxLabel.Text = (tax)
shippingLabel.Text = (ship)
totaldue = subtotal + tax + ship
totalDueLabel.Text = totaldue.ToString("C2")

My professor replied with: "If I understand the problem correctly, you just need to define your grand totals at a global level (at the top the form class). That way the totals aren't cleared back to zero at the end of the click event."

--I have tried multiple times to declare a variable and put it at the top, but still feel like a deer in the headlights. Any help would be much appreciated.

• Edited by Tuesday, April 18, 2017 5:37 AM
Tuesday, April 18, 2017 2:55 AM