The Student Room Group

Help with Visual Basic please?

In Visual Basic, I have a list box, listing product codes, quantity and price for anything a user selects from a database. I have a label (lblTotal) which I want to display the total price of all the products in the list. Anyone know how I can do this? At the moment the code I have in the listbox is:

lstProducts.AddItem txtQty & " " & _
txtCode & " " & "@" _
& " " & txtPrice

The data from the database is displayed in text boxes, hence txtQty, txtCode and txtPrice.

Also any help on how to space them out across the list rather than putting big spaces in would be great. Cheers.

EDIT: Okay don't worry about the first part, I've figured that out, about spacing it out without having to actually put spaces though, if anyone knows how to do that, that'd be great.
I think you can use the Tab functionality, although I am not sure if it works for on-screen output the same as it does for printed out. For example:
lstProducts.AddItem txtQty & Tab & txtCode & Tab & txtPrice
Also for the calculation of the Total Price for all products you would probably need to do some sort of Do While Loop which contained a temporary variable to store the individual price of each item.

Latest

Trending

Trending