I want to make increment and decrement counter.
There are two buttons called X and Y. First press X and then press Y counter should increment.
First press Y and then press X counter should decrement.
I am not familiar with c#. So can anyone help me please ?? :(
c# increment and decrement counter
Started by nikiarora, Aug 30 2009 08:28 AM
2 replies to this topic
#1
Posted 30 August 2009 - 08:28 AM
|
|
|
#2
Posted 30 August 2009 - 09:44 AM
By counters do you mean variables? Declare a variable in the form class.
Then double-click a button and there (in the Click event handler, but sounds a bit tech'ie) you put an incrementation statement.
Does it help ya? ;)
int counterX = 0; int counterY = 0;
Then double-click a button and there (in the Click event handler, but sounds a bit tech'ie) you put an incrementation statement.
counterX++; //or counterY--;
Does it help ya? ;)
proudly presenting my personal website and game website: F1Simulation. a thrilling Managed DirectX racing game... also my Ask Me
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
#3
Posted 30 August 2009 - 11:37 AM
That is how you would need to do it is with two variables and either the post-decrement or post-increment operators.
Basically x++ means to increase x by one after evaluating x. Thus, x-- means after evaluating x to decrease x by one. If you place the ++ and -- before the variable names then the variables are incremented or decremented before they are evaluated.
Basically x++ means to increase x by one after evaluating x. Thus, x-- means after evaluating x to decrease x by one. If you place the ++ and -- before the variable names then the variables are incremented or decremented before they are evaluated.


Sign In
Create Account

Back to top









