I'm trying to make button2 calculate all the items in the list. It worked but when you click calculate button again, it will continue adding. Is there a way to stop that (Newb coder here)?
private void button2_Click(object sender, EventArgs e)
{
Total1.Text = "0";
Boolean isValid = true;
//(Red)
//(Blue)
//(Yellow)
if (ListBox2.Items.Contains("(Red) "))
{
Health += 10;
Total1.Text = Health.ToString();
}
else if (ListBox2.Items.Contains("(Red) "))
{
Health += 1;
Total1.Text = Health.ToString();
}
// no click
else
{
MessageBox.Show("Error");
}