CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: timers

  1. #1
    Join Date
    Aug 2001
    Posts
    28

    timers

    i wanna to know how much it will take to do some loop....how can i put a timer for it?


  2. #2
    Join Date
    Aug 2001
    Posts
    5

    Re: timers

    You need to start the timer when the loop starts and end the timer when the loop stops and record it into a label control. I don't know how accurate you want to be but if you want it to be to the second then set the interval on the timer to 1000 and set the timers enabled property to false then...

    Do while a <> b
    timer1.enabled = true
    loop

    and under the timer put...

    dim time, add
    add = 1
    time = label1.caption
    label1.caption = time + add

    * don't forget to make label1.caption = "0" before you start the timer. *


    hope I could help. If you want to make it more accurate there is a topicon the forum that goes into further detail on timers.


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: timers

    Dim dS As Date 'start
    Dim dF As Date 'finish
    Dim vE As Variant'elapsed time

    dS = Now()
    dF = Now()
    vE = Format$(dF - dS, "hh:mm:ss")
    MsgBox vE

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: timers

    in a module declare

    public Declare Function GetTickCount Lib "kernel32" () as Long



    (or in a form)

    private Declare Function GetTickCount Lib "kernel32" () as Long



    and then in your sub do


    Dim t as Long
    ...

    t = GetTickCount
    Do While a < 10000
    ...
    Loop
    t = GetTickCount - t 'This is in Milliseconds




    ----------
    The @host is everywhere!
    ----------

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

Featured