Removing ListBox item, subtracting value

I would like to thank all those who helped me out earlier, but I have another question for those who don't mind... I have a Combo Box on my form with various data items with price values.  When the user clicks on the combo box, a drop down list pops up, and they select their product.  The price value is then added to the lblTotal (running total) and added to lstSelected (the list that holds everything they selected).  However, how do I have an item removed if they choose to change their mind and choose another option from the combo box AND have the lblTotal subtract the amount given earlier?  
  I've been knocking my head earlier on this one.  Thanks
Who is Participating?
eab111098Connect With a Mentor Commented:
i'm assuming that the user will have physically remove the item added to the control lstSelected. the following is code to complete that task.

Private Sub lstSelected_Click()
  lblTotal = lblTotal - val(lstSelected.list(lstSelected.listindex))
  lstSelected.Removeitem lstselected.listindex
end sub

hope this helps
verselloAuthor Commented:
Adjusted points to 61
verselloAuthor Commented:
I was hoping that it would be done automatically... if you know how, I would really appreciate it, but otherwise, this will do as well... Thanks
if they choose another item and you want the last item added to the lstselected listbox, then you simply record the index to where the item was added.

with the index recorded, you simply put my previous code in some function and call it when the user clicks an item in combo box. in the function that you will build from the above code, you would need to simply change the lstSelected.listindex to the index variable that is storing the index value of the item you just added.

All Courses

From novice to tech pro — start learning today.