Hi,
I am currently working on a VB form for a college assignment. I am trying to add quantities from a ListBox and then display the result in a TextBox for a pizza delivery order by using a button. So far, the Listbox shows:
pizza type
Quantity
pizza price
Total pizza price

The Total pizza price is the value that I want to add together and then show in a TextBox as an Order Price.

This is my form and Code for the button:

form1.PNG form.PNG
form1_buttoncode.PNG

The code is a work in progress and as you can see it has only added together the last pizza price with itself. I need to make it add each "Total_pizza_price" that appears in the list instead of only the last item.

Answers and solutions will be much appreciated,
Thank you.

Recommended Answers

All 5 Replies

Try To write a method that extracts the last price from a listbox item.
Sum those prices in a loop and fill in the text of your textbox.

You can do it by using a STRUCTUREwhich can give you full functionality to solve your problem.

Read this post you can get your way to solve the problem by yourself.

commented: Nice +15

You need a global variable which is outside the subroutine to represent the Total_pizza_price. This will enable you to add the individual prices to Total_pizza_price but it has to be set to zero at the beginning of of the subroutine, so that anytime you start to process a new order, the previous price will be cleared and the variable for Total_pizza_price will be set to zero.

Im having trouble understanding how to write the code... I should mention that I am at a very begginer level and don't know a lot about coding yet. I appreciate everyone trying to help :) Is there any way you can explain more about the solution.

Post your codes and problems where from we can help you to solve your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.