Results 1 to 4 of 4

Thread: using the timer event , help needed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    UK
    Posts
    300
    Hi
    VB is easy when you know how, unfortunatly I don't know how
    to do this:

    My program needs to import a file every 2 hours without fail
    from c:\reeldata_project , how do I use the timer to achieve
    this as I have never used the timer before. The file is getting
    loaded into an access data base ( which I have managed to do ).
    This prog will run 24hrs a day.

    Any help would be great.
    Thanx, Locutus
    Resistance is futile

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Add a timer to the form.

    Code:
    Private Sub Form_Load()
      Timer1.Index = 120000
      '2 hours in miliseconds (I think)
      Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
      AssimilateThatImportantFileHere
    End Sub

    That's it!

    //Anders

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    It's not quite that easy

    the Controls have a maximum interval of 65,535 milliseconds (just over 1 minute)


    you could use a timer to check the time at 1 minute intervals...
    Code:
    Option Explicit
    Dim NextRunTime As Date
    Private Sub Form_Load()
    Timer1.Interval = 60000
      ReSetNextRunTime
    End Sub
    Public Sub ReSetNextRunTime()
     
      NextRunTime = DateAdd("n", 120, Now)
    End Sub
    Private Sub Timer1_Timer()
     If Now >= NextRunTime Then
        
       'invoke code to run here
       
       
       
       'and reset the next run time
        ReSetNextRunTime
      End If
    End Sub
    Mark
    -------------------

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Option Explicit

    Private Sub Form_Load()
    'set timer to check at just under 1 minuite intervals
    'remember..timers are not as accurate as clocks..they
    'do have missed moments...not big but over time they
    'can make a slight difference

    Set Timer1.Interval = 58000

    End Sub

    Private Sub Timer1_Timer()

    Dim curTime As Date
    curTime = Format(Now, "hh:mm AMPM")

    If curTime = "12:01 AM" Or curTime = "02:00 AM" _
    Or curTime = "04:00 AM" Or curTime = "06:00 AM" _
    Or curTime = "08:00 AM" Or curTime = "10:00 AM" _
    Or curTime = "12:01 PM" Then

    MsgBox "Its time to do your whatevers"

    End If

    End Sub
    [/code]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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