I’m using VB 2008. I need to

write a simple program that calculates total sales of purchases. The program should accept item costs as input calculate the tax on each item (8%) display the item cost, total cost, and total after taxes. Item costs will be added to a listbox while the total without the taxes will be displayed in a label, the tax amount in another label, and finally, the total cost (items cost + tax) in a third label.

*******CODE********

Public Class Form1
Dim strTotal As Double = 0

Private Sub txtItemCost_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtItemCost.Enter

' select the Item Cost
txtItemCost.SelectAll()

End Sub

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

' declare valiables
Dim strTaxAmt As Double
Dim strTotalTax As Double
Dim strItemCost As Double
Dim strTotal As Double

' add items listbox
strItemCost = CDbl(lstItemCosts.Text)
strTotal = strTotal + strItemCost ' add to running total

' calculates totals
strTaxAmount = strTotal * 0.08
strTotalWTax = strTotal + strTaxAmount

txtTotal.Text = strTotal
txtTaxAmount.Text = strTaxAmount
txtTotalWTax.Text = strTotalWTax

' insert a dollar sign as the first character
strTotal = strTotal(0, "$"), "Currency")
strTaxAmount = strTaxAmount(0, "$")

Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()

End Sub

End Class

What exact problem are you seeing when you run the program? If I start there, it is usually easier to solve.

The code provided seems to have a few errors and missing parts. Let's go through the steps to write a simple program that calculates total sales of purchases in VB 2008.

1. Create a new Windows Forms project in VB 2008. Name it whatever you prefer.

2. Drag and drop the following controls from the Toolbox onto the form:
- TextBox (for entering item cost): Name it "txtItemCost"
- Button (for adding item cost to the list): Name it "btnAdd"
- ListBox (for displaying item costs): Name it "lstItemCosts"
- Label (for displaying the total cost without taxes): Name it "lblTotalCost"
- Label (for displaying the tax amount): Name it "lblTaxAmount"
- Label (for displaying the total cost with taxes): Name it "lblTotalWithTaxes"
- Button (for exiting the program): Name it "btnExit"

3. Double-click on the Form to open the code-behind.

4. In the code-behind, replace the existing code with the following code:

```vb
Public Class Form1
Dim totalCost As Double = 0

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
' Get the item cost from the textbox and convert it to double
Dim itemCost As Double = CDbl(txtItemCost.Text)

' Calculate tax on the item cost (assuming 8% tax)
Dim taxAmount As Double = itemCost * 0.08

' Add the item cost to the total cost without taxes
totalCost += itemCost

' Display the item cost in the listbox
lstItemCosts.Items.Add(itemCost)

' Display the total cost without taxes
lblTotalCost.Text = totalCost.ToString("C")

' Display the tax amount
lblTaxAmount.Text = taxAmount.ToString("C")

' Display the total cost with taxes
lblTotalWithTaxes.Text = (totalCost + taxAmount).ToString("C")

' Clear the textbox for the next item cost
txtItemCost.Clear()
End Sub

Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
' Close the form
Me.Close()
End Sub
End Class
```

5. Save the changes and run the program.

Now, you should be able to enter item costs in the textbox and click the "Add" button to add them to the listbox. The total cost without taxes, the tax amount, and the total cost with taxes will be displayed in the respective labels. Clicking the "Exit" button will close the program.

Note: Ensure that you have the necessary references and imports added to your project if needed.