Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Value in second Column of a list box

Status
Not open for further replies.

lshields

Technical User
Nov 16, 2003
20
US
I have a form with multiple list boxes on it in which are displayed an item and the price of the item. I want to calculate the total price of the items selected from all of the list boxes on a form and place this price in a text box. My main problem is grabbing the price from the second column of the list box without making column 2 the primary column. How can I do this efficiently?

Any Suggestions would be appreciated.

Thanks
 
You "add" the item price(s) as you add items to the listbox. For example:

Private Sub Add_Click()
Dim varItem as Variant
Dim curExtPrice as Currency ' The price per item * quantity of that item.
Dim curSubTotal as Currency

' Each item selected from the stock Listbox (assuming you have a list box from which the client selects the items for purchase
For Each varItem In lstStock.ItemsSelected

' Add the code for adding the item to the purchase listbox

curExtPrice = lstStock.Column(2, varItem) * txtQuantity ' txtQuantiy is a text box for the Qty to be purchased
' the ...Column(2,...) #2 repsents the column in the "Stock" listbox that contains the price of the item
' That column # maybe different for you!

curSubTotal = curSubTotal + curExtPrice ' Accumulate the total

next varItem

Hope this helps

_________________
Paladine

"Doing what others find difficult is talent.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top