Results 1 to 3 of 3

Thread: Timer

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Hi!
    I'm using the following code to make a timer fucntion:
    code:
    PauseTime = 1
    Start = Timer
    Do While Timer < Start + PauseTime
    DoEvents
    Loop
    Finish = Timer
    TotalTime = Start - Finish

    It works fine, but i want to be able to change the Interval (PauseTime)
    I have tried:

    SaveSetting "Timer" , "Timer" , "Timer" , "0.05"
    Dim Interval
    Interval = GetSetting("Timer" , "Timer" , "Timer")

    PauseTime = Interval
    Start = Timer
    Do While Timer < Start + PauseTime
    DoEvents
    Loop
    Finish = Timer
    TotalTime = Start - Finish

    But instead of an interval on 0.05 sec. , the interval is 5 secs!!
    What is wrong???

    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can create a sub routine which will except one parameter that will tell it the interval:
    Code:
    Public Sub TimeOut(pInterval As Single)
        Dim sngTimer As Single
        
        sngTimer = Timer
        Do While Timer < sngTimer + pInterval
            DoEvents
        Loop
    End Sub
    Then you can call it like:


    TimeOut 3


    This will pause for 3 seconds.

  3. #3
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    If you using a timer control then the timer interval is measured in milliseconds, thast 1000 milliseconds per second, so:

    1 second is 1000 therfore
    timer1.interval=1000

    and 0.5 seconds is 500 therefore
    timer1.interval=500

    and .05 seconds is 50 therefore
    timer1.interval = 50
    Savvy?

    {;->
    DocZaf


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width