For remove button in main form, I have:

'Remove selected item

If lstShoppingCart.SelectedItems.Contains("I Did It Your Way (Print)") Then

lstShoppingCart.Items.Remove("I Did It Your Way (Print)")

End If

To calculate charges, I have:

Private Sub DisplayCharges()

Dim decSubTotal As Decimal

Dim decTax As Decimal

Dim decShipping As Decimal

Dim decTotal As Decimal

'Calculate the subtotal charges.

decSubTotal = g_decSubtotal

'Calculate the tax charges.

decTax = g_decSubtotal * decSALES_TAX

'Calculate the shipping charges.

decShipping = g_intItemCount * decSHIPPING_CHARGE

'Calculate the total charges.

decTotal = g_decSubtotal + decTax + decShipping

'Display the data.

lblSubTotal.Text = FormatCurrency(decSubTotal)

lblTax.Text = FormatCurrency(decTax)

lblShipping.Text = FormatCurrency(decShipping)

lblTotal.Text = FormatCurrency(decTotal)

Now I need to reduce charges when the User uses the Remove button_click to remove an item from the ListBox (2 subforms with 4 items each).

Any suggestions

Re: Visual Basic Express Edition Remove ListBox item charges in multi-form project?

Bruno Yu - MSFT


Please try the code below:

Private Sub btnRemove_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles btnRemove.Click

' Count backwards to avoid numbering issues when

' removing items.

For i As Integer = lstFoods.Items.Count - 1 To 0 Step -1

If lstFoods.GetSelected(i) Then


End If

Next i

End Sub

The code is from a sample project named Save and restore ListBox items when a program stops and starts in Visual Basic .NET in VB-Helper website. Please take a look at the article and try the sample project: