Results 1 to 4 of 4

Thread: simple timer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    NJ
    Posts
    19

    Exclamation

    I'm quite new at vb and was wondering if someone could show me how to make a simple timer. Like have a label say "1" then "2" then "3" and so on.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'in declarations
    Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    
    'in code
    Dim t&
    t=gettickcount
    Do
     doevents
     label1=int((gettickcount-t)/1000))
    loop until YouWantItToStopBooleanValue
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    Here is an example using the Timer function. The DoEvents lets Window's do other tasks so your computer does not freeze.

    Code:
    Go = Timer
    
    Do Until Timer > Go + 3
        DoEvents  
        ' place other code here
        MyNum = MyNum + 1
    Loop
    
    Print MyNum

  4. #4
    Guest
    Code:
    Function timeout(interval)
    Current = Timer
    Do While Timer - Current < Val(interval)
    DoEvents
    Loop
    End Function
    
    'create a timer and set its interval to 100
    'in the timer put:
    For i = 0 to 10 'count to 10
    Label1.caption = i 'count 1 to 10 showing contents on label
    Timeout .01 'timeout
    Next 'loop until 10
    Timer1.enabled = False 'turn timer off after 10

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