As you can see in the attached picture, once you add an item to the listbox on the right, the item is removed from the left listbox (as it should).
Public Class SupplyCalculatorForm
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim selectedItems = (From i In stockListBox.SelectedItems).ToArray()
For Each selectedItem In selectedItems
shoppingListBox.Items.Add(selectedItem)
stockListBox.Items.Remove(selectedItem)
removeButton.Enabled = True
calculateButton.Enabled = True
Next
End Sub
Private Sub removeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles removeButton.Click
stockListBox.Items.Add(shoppingListBox.SelectedItem)
shoppingListBox.Items.RemoveAt(shoppingListBox.SelectedIndex)
End Sub
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
Dim i As Integer
Dim prod
Dim total
Dim sum
i = stockListBox.ListIndex
prod = stockListBox.List(i)
If stockListBox.Count > 0 Then
shoppingListBox.Items.Add(prod)
Else
MsgBox("Please select item first")
End If
sum = 0
For i = 0 To stockListBox.ListCount
sum = sum + Val(stockListBox.List(i))
Next i
totalLabel.Text = sum
End Sub
End Class ' SupplyCalculatorForm
Attached File(s)
-
shoppingcart.bmp (337.03K)
Number of downloads: 18

New Topic/Question
Reply




MultiQuote


|