using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication22
{
    public partial class Form1 : Form
    {
        private double subTotal = 0;
        public Form1()
        {
            InitializeComponent();
        }


        private void btmAddItem_Click(object sender, EventArgs e)
        {


            double numberOne;
            double numberTwo;
            double total;
            double Counter;


            numberOne = Convert.ToDouble(txtQuantity.Text);
            numberTwo = Convert.ToDouble(txtPrice.Text);

            total = numberOne * numberTwo;
            Counter = total;
            subTotal = 0;
            listBox1.Text = Convert.ToString(total);
            lblSub.Text = Convert.ToString(total);


            listBox1.Items.Add(txtName.Text.PadRight(60) + txtQuantity.Text.PadRight(35) + txtPrice.Text);
            listBox2.Items.Add(total);
            lblTotal.Text = listBox2.Items.Count.ToString();

            int i = 0;
            for (i = 0; i < listBox2.Items.Count - 1; ++i);
            foreach (var item in listBox2.Items)



            txtName.Text = "";
            txtQuantity.Text = "";
            txtPrice.Text = "";
        }
    }
}

Welcome to Daniweb :)

What is the meaning of lines 47 and 48? Two loops with no statements to loop?
Lines 52,53 and 54 reset always your textboxes to empty strings after a click of your button. Is that the intention?

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.