Results 1 to 2 of 2

Thread: One cycle Timer in VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    73

    One cycle Timer in VB6

    Hi all,
    i understand that the timer in VB6 is counting endllessly based on the interval set. i would like to to have a timer that only count once (say 3 sec) and execute the event. can someone kindly help me in this.

    longwar

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: One cycle Timer in VB6

    just disable the timer at the end of the timer's event:
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Timer1.Interval = 3000 '3 secs
    4. Timer1.Enabled = True
    5.  
    6. End Sub
    7.  
    8. Private Sub Timer1_Timer()
    9.  
    10. MsgBox "hello"
    11. 'and all your code
    12. Timer1.Enabled = False 'event executed only once or work whenever you
    13. 'enable the timer explicitly
    14.  
    15. End Sub
    Show Appreciation. Rate Posts.

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