Android Question change a timer interval

Discussion in 'Android Questions' started by Devv, Feb 20, 2015.

  1. Devv

    Devv Active Member Licensed User

    How could i change a timer interval ?

    is initializing a timer more than once safe ?
     
  2. NJDude

    NJDude Expert Licensed User

    Using INTERVAL, check the Timer's intellisense.
     
    thedesolatesoul and DonManfred like this.
  3. Devv

    Devv Active Member Licensed User

    NJDude
    Could you please explain more ?
    sorry i'am new to basic language ...
     
  4. NJDude

    NJDude Expert Licensed User

    thedesolatesoul and Devv like this.
  5. Devv

    Devv Active Member Licensed User

    i had already red it ..
    it does not talk about changing timer interval , it only say about initializing the timer for the first time
     
  6. NJDude

    NJDude Expert Licensed User

    Well, read it again, it says right there:
    Code:
    Interval As Long
    Gets 
    or sets the interval between tick events, measured in milliseconds.
     
    thedesolatesoul and Devv like this.
  7. Devv

    Devv Active Member Licensed User

    so at the second time i dont have to use this

    Initialize (EventName As String, Interval As Long)

    i should only use
    timer1.interval = 2000


    am i right ?
     
  8. NJDude

    NJDude Expert Licensed User

    Have you tried?
     
    thedesolatesoul and Devv like this.
  9. Devv

    Devv Active Member Licensed User

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        test.Initialize(
    "test",2000)
        test.Enabled = 
    True
    End Sub

    Sub test_tick
        
    ToastMessageShow("test",False)
        test.Interval = 
    6000
    End Sub
    ya this code is working perfectly , thanks for help dude , you are noobs hero :D
     
  10. NJDude

    NJDude Expert Licensed User

    My pleasure.
     
    thedesolatesoul likes this.
  11. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Yes you're right, you don't need to initialise it again. I normally call a sub to stop the timer, set the new interval and then restart the timer to ensure that the first tick event is from time 0 to the interval time eg.
    Code:
    ..... ' your other code
        tmr_Reset(2500' reset timer to 2.5s interval
    ....


    Sub tmr_Reset(ms As Int)
        tmr.Enabled=
    False
        tmr.Interval=ms
        tmr.Enabled=
    True
    End Sub
     
    thedesolatesoul likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice