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
verselloAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

verselloAuthor Commented:
Adjusted points to 61
0
eab111098Commented:
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
ed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
0
eab111098Commented:
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.

ed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.