my label wont keep the total, it just resets after the next

Nov 29 2015 1:15 PM

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 = "";

}

}

}


Answers (1)