Adding values from a multiselect listbox?
Posted on 2006-06-16
I’m doing a self study in Visual basic. I’m currently working on exercise 13.3.2 of ‘An Introduction to Programming using Visual Basic 6 by David I. Schneider’ with a few adjustments!!
The exercise is about a Fast Food Restaurant.
Here’s what I’ve done so far:
First I created a database in Access called FOCS, I have two tables called MenuItems & DrinkItems –
Next, I created a form in Visual Basic 6. I have two ADODC controls with connections to FOCS; ADOCMenu & ADOCDrinks.
I placed two DataList boxes onto the form; DataList1 & DataList2
DataList1 source is ADOCMenu & DataList2 source is ADOCDrinks.
Ok, this work perfectly fine. I can display my Food & Drinks Items in DataList1 & DataList2.
Next I created a listbox (lstOrder) for my orders and cmdButtons (button >>> & button <<<)
I want to multi-select items from DataList1 & DataList2 and display these items in lsdOrder – the code I’ve used is:
Private Sub cmdMoveItem_Click()
Do While adoMenu.Recordset.Fields("Items") <> DataList1.Text
lstOrder.AddItem adoMenu.Recordset.Fields("Items") & " " & FormatCurrency(adoMenu.Recordset.Fields("Price"))
Ok, so far, all is well. I can multi-select Food & Drink items, click >>> or <<< Button’s and the items and price are then displayed in lstOrder box.
The next pit is where I’m stuck…….I’m tying to create a Total Cost (txtTotalCost) of all the items and price displayed in lstOrder……….can any help??