收到错误 "value '0' is not a valid value"
getting error "value '0' is not a valid value"
已编辑:
我正在写一个自动点击器,它快完成了,但它有一个奇怪的问题...
在 btnStart 事件中我写了:
if (listViewPositions.Items.Count == 1)
{
ClickIntervalStr1 = (listViewPositions.Items[(1) - 1].SubItems[(3) - 1].Text).ToString();
ClickIntervalNum1 = Convert.ToInt32(ClickIntervalStr1);
LeftOrRightClickStr1 = (listViewPositions.Items[(1) - 1].SubItems[(4) - 1].Text)
.ToString();
SingleOrDoubleClickStr1 = (listViewPositions.Items[(1) - 1].SubItems[(5) - 1].Text)
.ToString();
}
在计时器(点击过程)中我写了:
timerClickProcessStopAfterXTimes.Interval = ClickIntervalNum1;
但是当我按下开始按钮时出现此错误:"Value '0' is not a valid value for interval. interval must be greater than 0."
我确定一切正常,但为什么会出现此错误?!
图片如下:
请帮忙...
已修复:
我只需要写 4 行代码 listViewPositions.Items.Count == 1
到 listViewPositions.Items.Count == 2
以及其他...
"Value '0' is not a valid value for interval. interval must be greater than 0."
显而易见的原因是因为 ClickIntervalNum1 = Convert.ToInt32(ClickIntervalStr1);
。 ClickIntervalStr1
的价值明显体现在 0
...
Microsoft 关于 Interval
属性:
The time, in milliseconds, between Elapsed events. The value must be greater than zero, and less than or equal to MaxValue. The default is 100 milliseconds.
要解决此问题,只需确保它大于 0
...(简单示例):
timerClickProcessStopAfterXTimes.Interval = ClickIntervalNum1 > 0 ? ClickIntervalNum1 : 100;
参考文献:
Timer.Interval Property System.Timers
已编辑:
我正在写一个自动点击器,它快完成了,但它有一个奇怪的问题...
在 btnStart 事件中我写了:
if (listViewPositions.Items.Count == 1)
{
ClickIntervalStr1 = (listViewPositions.Items[(1) - 1].SubItems[(3) - 1].Text).ToString();
ClickIntervalNum1 = Convert.ToInt32(ClickIntervalStr1);
LeftOrRightClickStr1 = (listViewPositions.Items[(1) - 1].SubItems[(4) - 1].Text)
.ToString();
SingleOrDoubleClickStr1 = (listViewPositions.Items[(1) - 1].SubItems[(5) - 1].Text)
.ToString();
}
在计时器(点击过程)中我写了:
timerClickProcessStopAfterXTimes.Interval = ClickIntervalNum1;
但是当我按下开始按钮时出现此错误:"Value '0' is not a valid value for interval. interval must be greater than 0."
我确定一切正常,但为什么会出现此错误?!
图片如下:
请帮忙...
已修复:
我只需要写 4 行代码 listViewPositions.Items.Count == 1
到 listViewPositions.Items.Count == 2
以及其他...
"Value '0' is not a valid value for interval. interval must be greater than 0."
显而易见的原因是因为 ClickIntervalNum1 = Convert.ToInt32(ClickIntervalStr1);
。 ClickIntervalStr1
的价值明显体现在 0
...
Microsoft 关于 Interval
属性:
The time, in milliseconds, between Elapsed events. The value must be greater than zero, and less than or equal to MaxValue. The default is 100 milliseconds.
要解决此问题,只需确保它大于 0
...(简单示例):
timerClickProcessStopAfterXTimes.Interval = ClickIntervalNum1 > 0 ? ClickIntervalNum1 : 100;
参考文献:
Timer.Interval Property System.Timers