• 0

[C# .Net] Changing timer interval at runtime?


Question

12 answers to this question

Recommended Posts

  • 0

Well to make life easier, I decided to use NumericUpDown control.

I tried this code, but I just get a error :/

Maybie it just a silly mistake, I have no idea.

timer1.Interval = int.Parse(numericUpDown1.Value) * 60000;

Sorry about these rather silly questions tho :unsure:

  • 0
  virtorio said:
Try this:

timer1.Interval = int.Parse(numericUpDown1.Value.ToString()) * 60000;

But what i don't get is, why do you even need to parse it, when the numericupdown control provides a value back, and all u need is basically (numericUpDown1.Value * 6000)

  • 0
  Winston said:
But what i don't get is, why do you even need to parse it, when the numericupdown control provides a value back, and all u need is basically (numericUpDown1.Value * 6000)

Because the data-type of the Value property of the numberic up/down control is of type Decimal, which contains extra functionality, so it must therefore be converted to an int value.

The example I gave above actually isn't very good, a better way to perform the convertion would be:

timer1.Interval = Decimal.ToInt32( numericUpDown1.Value );

  • 0
  virtorio said:
Because the data-type of the Value property of the numberic up/down control is of type Decimal, which contains extra functionality, so it must therefore be converted to an int value.

The example I gave above actually isn't very good, a better way to perform the convertion would be:

timer1.Interval = Decimal.ToInt32( numericUpDown1.Value );

Oh i always thought the value method, returned integer type.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.