Results 1 to 2 of 2

Thread: Visual Basic Advance Timer

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Location
    Pakistan
    Posts
    7

    Resolved Visual Basic Advance Timer

    Did you coded or experienced a timer with more then 60 seconds interval
    or a timer with maximum cap limit ?

    Here it all now :

    Functions:-
    1. Intervals 1 , 5 , 10 and 15 minutes
    2. Maximum Timer Life 1 , 2 ,3 and infinity hours


    Name:  TimerCodePreview.jpg
Views: 2677
Size:  45.5 KB

    Code:
    Code:
    Public Function StartTimer(bInterval As Double, Optional bMax As Double)
    Dim MiliCounter  As Double, Infinity As Boolean
    If bMax = 0 Then
    Infinity = True
    End If
    mMax = bMax ‘Maximum Second , -1 for infinity
    mInterval = bInterval ‘Interval Second
    MiliCounter = -1 ‘bypass millisecods (timer is for seconds only)
    StartTime = GetTickCount() ‘Get currunt system timer tick
    Do While TimerEnabled = True
    TimePassed = Int((GetTickCount() – StartTime) / 1000) ‘Convert to seconds
    If Infinity = False Then
    If TimePassed > mMax Then TimerEnabled = False ‘look for Maximum Second
    End If
    If (TimePassed Mod mInterval = 0) And (TimePassed > MiliCounter) Then
    ‘TimePassed Mod mInterval = 0   ‘look for Interval Second
    ‘TimePassed > MiliCounter       ‘look for next second
    MiliCounter = TimePassed
    ‘/////////////Main Interval Code////////////
    Debug.Print “time consumed “; TimePassed
    Call InvokeIntervalEvent
    ‘///////////////////////////////////////////
    End If
    DoEvents
    Loop
    End Function
    Call the function as This:
    call StartTimer( 1 * 60, 1 * 3600)
    i.e StartTimer for 60 sec intervel and 1 hour life

    Happy Coding…


    Example is coded in following Post
    Last edited by FunkyDexter; Feb 11th, 2016 at 05:30 AM.

Tags for this Thread

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