Results 1 to 3 of 3

Thread: Still wondering about the Timer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 1999
    Location
    Turner ME USA
    Posts
    18

    Post

    I sent this message earlier, I got a response but am still confused how to utilize this code. Any more help or advice would be appreciated!


    I am using a Timer in a project, but the interval for that control only lasts just over 1 minute and I need up to 30 minutes of time! Any suggestions on how to make a timer for up to 30 minutes?

    Thanks!
    Jeff


    11-28-1999 12:06 PM

    One very simple way: Set your timer's interval to 1 and use this as your code for
    it:

    Static OldTime
    If OldTime = "" Then OldTime = Time
    If DateDiff("n", CDate(OldTime), Time) = 30 Then

    OldTime = ""

    MsgBox "30 Minutes has elapsed.", vbInformation, "Time"

    End If


  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    I believe he wants you to put that in your Timer1_Timer event. I would also set your interval property of your timer to 1000 (1 second) or even higher so you don't kill your CPU utilization.

    Also, change this line:
    If DateDiff("n", CDate(OldTime), Time) = 30 Then

    TO:

    If DateDiff("n", CDate(OldTime), Time) => 30 Then

    so in case your code misses 30 (for whatever reason) your code will still be triggered and timer reset.

    HTH

    Tom

  3. #3
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Post

    You can use one of two ways.

    -------
    MyDelay = Timer + (30 * 60) ('30 times 1 minute)
    While MyDelay > Timer
    Wend
    -------

    This will stop execution for 30 minutes.

    The other way is to set the timer interval to 1 minute (60000, as the timer clicks on milliseconds), and then count to 30:

    On Timer event:
    -------
    Times = Times +1
    If Times = 30 Then
    Times = 0
    'do your stuff
    End IF
    -------

    This counts 30 times the 1 minute interval, and will not hang your app for that half an hour. Don't forget to declare the Times variable in the General Section or in a Module, for not losing its value!

    Hope to be helpful.

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