I have a class with some constructors,a form with a command button and 1 public variable set to 20 at my “form.cs”. How can i decrement the variable every time i click on the button until it becomes zero? I tried a few methods such as a loop inside the click event, a simple deduction in the constructor(variable = variable -1) but they dont work!
Tried this:
public void AssignSeat()
{
seats = seats - 1;
}
and then
private void button2_Click(object sender, EventArgs e)
{
Class1 Class1 = new Class1();
Class1.AssignSeat();
Class1.MSGbox();
}
It compiles and runs w/o errors but it never stops!
Declare iCount & iTemp outside button click
int iCount = 0;
int iTemp = 20;