• 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.
  • Posts

    • The best thing would be to just allow more options to let users pick the layout they like, it doesn't matter at this point really and it's not that hard to do as evidenced but all the 3rd party menus/tools that let you change it in lots of different ways. If you give the users more options they'll be happy, take them away and you have a problem.
    • They could've done that the very next day or from the start but when Win11 came out, the MSN team was still rooted in the OS division and pushing for it's hooks into everything. That's why we have recommended and all the MSN feed stuff in the widget panel which you also couldn't turn off at the start. Now that they've been pushed out, last I checked, all this MSN/web feed junk is finally getting the option to be turned off. tl/dr, it's not about coding ability, it's just dumb business decisions.
    • The headline doesn't fit the article. Sure the headline is more enticing probably, but come on, man. Keep it real, if you can help it.
    • The console sales don't mean much like they used to. Sony tells you this themselves but you seem to miss it. They care more about MAUs and how many people they can milk each month than x number of consoles sold, often to the more casual COD, Madden or FiFA gamers who play little else. Sony can't seem to port their games to the PC fast enough because they're not getting enough out of that 75 million console sales it seems. The traditional home console market has stagnated already, everyone knows it.
    • That is fair, I meant the comment somewhat whimsically and as such was a bit careless with the facts. Had I said either 2 or 4 that would be more defensible. SpaceX's Starship crashed 2 times during hop tests and 2 additional hop-test failures that while not exactly a "crash," still resulted in the total destruction of the test vehicle. Even in that example, it would still be fair for you to point out that Starship is a significantly more complex test vehicle and that SpaceX never crashed a simple rocket hop-test like this one. I already admitted that I could have been clearer, but I also don't think it unreasonable to use the word "it" when referring to the subject of the article I am commenting on. I feel like it is an outlying read of my words to assume "it" meant SpaceX's total success. Like I said, I accept responsibility for the ambiguity.
  • Recent Achievements

    • Week One Done
      slackerzz earned a badge
      Week One Done
    • Week One Done
      vivetool earned a badge
      Week One Done
    • Reacting Well
      pnajbar earned a badge
      Reacting Well
    • Week One Done
      TBithoney earned a badge
      Week One Done
    • First Post
      xuxlix earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      681
    2. 2
      ATLien_0
      285
    3. 3
      Michael Scrip
      225
    4. 4
      +FloatingFatMan
      197
    5. 5
      Steven P.
      136
  • Tell a friend

    Love Neowin? Tell a friend!