So im actually creating a fastfood menu in which save how many times a button been clicked as a variable. So I can multiply it to its value. For example if i click btnChicken a variable will count how many btnChicken been clicked then it will multplied on the amount i set for the value of each chicken.

As c++ doesn't have a GUI system I'd be guessing if this was in Visual Studio C++ or something else.

Even so, you would implement your code to that button's handler to do what you wrote above.

With a vague description and no code supplied it is almost impossible to figure out exactly what you want to do.

If the task is to count "every" click probably you may want to consider creating a user control.

Your code will look something like this -

int count = 1;

private void Page_Load(object sender, System.EventArgs e)
{
    Button btn = new Button();
    btn.Text = "Click Me";
    btn.Click  += btn_Click;
    lbl = new Label();
    form1.Controls.Add(btn);
    form1.Controls.Add(lbl);
}

protected void btn_Click(object sender, EventArgs e)
{
    count++;
    if(lbl !=null)
      lbl.Text = count.ToString();            
}

Good topic and some valid comments. Don't forget to display the quantity (number) each time the button is pressed, and there should also be a way to reduce the number if the customer changes his/her mind, or presses the button too many times by mistake.

Interesting topic with good replies. I'm just adding something very general as I work in a completely different area most of the year and want to avoid getting too rusty.
I'd start from the question: Who are you storing the data for, you, the client or both?
For you it's a database, for clients think javascript and local storage.
Are you sure you didn't mean .NET and C# ? Try Visual Studio.

It's always hard in the beginning just keep on doing it.
I remember when I had some problems with that.. .

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.