[英]Make Count reset
The issue I'm having is when I click stop the label resets to zero but when I click start again the counter starts where it last left off. 我遇到的问题是,当我单击“停止”时,标签重置为零,但是当我再次单击“开始”时,计数器从上次停止的地方开始计数。 I want to make the counter start at zero each time I click the start button.
每次单击开始按钮时,我都希望计数器从零开始。 Here is what I have:
这是我所拥有的:
//Perform mouse down followed by mouse up while counting the number of clicks performed.
int Count = 0;
private void PerformClick_Tick(object sender, EventArgs e)
{
Count++;
CountTxt.Text = Count.ToString();
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
//Convert our text to int to control our timer speed.
private void Speed_TextChanged(object sender, EventArgs e)
{
int SetSpeed = Int32.Parse(Speed.Text);
PerformClick.Interval = SetSpeed;
}
//Reset counter to zero after the program is stopped
private void Reset_Tick(object sender, EventArgs e)
{
if (PerformClick.Enabled == false)
{
CountTxt.Text = "0";
}
}
Seems like you forgot to reset your Count variable to zero. 似乎您忘记了将Count变量重置为零。
Try something like this: 尝试这样的事情:
private void Reset_Tick(object sender, EventArgs e)
{
if (PerformClick.Enabled == false)
{
CountTxt.Text = "0";
Count = 0;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.