locked
numeric up down to control timer interval RRS feed

  • Question

  • hello,
    having a bit of trouble making a numeric up down spin control change the interval of a timer.
    am I forgetting something on this?

    Code Snippet

        Private Sub btnTimedRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimedRefresh.Click

            Timer1.Interval = nudTimerAdjust.Value
            Timer1.Start()

        End Sub

        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            PictureBox1.Image = VideoSource1.SnapShot2Picture()
            Timer1.Stop()

        End Sub

    thanks in advance for the help
    Monday, May 7, 2007 2:52 PM

Answers

  • In order to change the timer interval you simply need to change its interval property, as it looks like you are.

     

    I'd ensure that for the numeric up down control you do set a maximum value, minimum value and not that the timer works in MS, so unless you are making reasonably large value changes then you wouldnt see and affect.   Changing interval from 1001 to 1002 is not going to be noticable.   Changing from 1000 to 5000 should be.

     

    That said, I'd probably keep the numeric control in integer increments (ie. 1,2,3,4,5) and then multiple this value by 1000 to get ms value.

     

    Timer1.Interval = NudTimerAdjust.Value * 1000

     

    This way they are adjusting the timer interval in 1 second increments - changing from 1 to 5 should be noticable.   But also ensure that max and min values are set and that the value is not 0.

     

     

     

     

    Monday, May 7, 2007 5:49 PM

All replies

  • What are the Maximum, Minimum, and Increment of the NumericUpDown control?
    Monday, May 7, 2007 3:23 PM
  • In order to change the timer interval you simply need to change its interval property, as it looks like you are.

     

    I'd ensure that for the numeric up down control you do set a maximum value, minimum value and not that the timer works in MS, so unless you are making reasonably large value changes then you wouldnt see and affect.   Changing interval from 1001 to 1002 is not going to be noticable.   Changing from 1000 to 5000 should be.

     

    That said, I'd probably keep the numeric control in integer increments (ie. 1,2,3,4,5) and then multiple this value by 1000 to get ms value.

     

    Timer1.Interval = NudTimerAdjust.Value * 1000

     

    This way they are adjusting the timer interval in 1 second increments - changing from 1 to 5 should be noticable.   But also ensure that max and min values are set and that the value is not 0.

     

     

     

     

    Monday, May 7, 2007 5:49 PM
  • the increment is 1
    the maximum is 15
    the minimum is 1


    want to give the ability to adjust the timer from 1 - 15 seconds at 1 second increments.

    thank you for the help
    Monday, May 7, 2007 7:22 PM
  • I think the answer is below.  You need to multiply the value by 1000.

     

    Timer increments are in MS,  your numeric up down control is providing a value in seconds.

     

    Multiply numeric up down control by 1000 when you set the interval and you should reflect the expected timer interval.

     

    Monday, May 7, 2007 7:30 PM
  • spotty,

    Timer1.Interval = NudTimerAdjust.Value * 1000

    the multiplying by 1000 did the trick - before it was just passing the amount of the numeric up down and when you only increase a timer by 3 ms it doesn't appear to wait at all when taking the picture.
    thanks for all the help

    Monday, May 7, 2007 7:32 PM
  • 3 ms is an awefuly short time interval. 

    Monday, May 7, 2007 9:42 PM