Results 1 to 4 of 4

Thread: Howto make a 24 h timer

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186

    Wink

    Hi there,
    I'm going to build an exe server component that has to be up only once a month, eg the last day of the month.
    On this day it will transfer files and write to a database. After it has finished it will have to wait until the next last day of the next month.
    Makes any sense?

    Well, I'm not sure on how to do this.
    My guess is that my exe will need a timer but only respondig every 24 hours and then asking if it is the last day of the month. How do I build such a timer?
    Is there another way to do this?

    Another thing, if the server is restarted, I would like the exe to also start again.

    Please help,

    Cheers,

    André

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

    <?>

    Add a timer to your form Timer1
    Code:
    'this should work
    
    Option Explicit
    
    Public sDone As Boolean  'marker for the last day finished
    sDone = False
    
    Private Sub Form_Load()
        Timer1.Enabled = True
        Timer1.Interval = 60000 'approx 1 min.
    End Sub
    
    Private Sub Timer1_Timer()
    'get last day of the mont
        Dim theLast
        theLast = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
    
    'check it against today and act accordingly
        If Format(Now, "dd") = theLast And sDone = False Then
            'do your file stuff
        'mark it as done to avoid doing it again
            sDone = True
         End If
         
    'reset to false after monthend
        If Format(Now, "DD") + 1 > theLast Then sDone = False
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    Thanx,
    Since VB timer approx. can only handle 65 seconds I did'nt want to use it. You know every minute in a month.

    I have found an API SetTimer, wich is a callback function that can callback as far as 23 days!!!

    So now I can almost wait an entire month almost!

    André

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

    <?>

    true enough, and if you refreshed your system daily you wouldn't need a timer, you could just store the variable with SaveSettings and check against it each day as you open and if a match then do your stuff.

    Later.
    "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