Results 1 to 6 of 6

Thread: Timers and Events......

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Manchester, England.
    Posts
    18
    Hi Guys

    Excuse my ignorance, but i am new to VB programming although i am experienced in Access programming.

    I am buliding a small VB app to compact and backup Access databases overnight. I have the whole thinking working on a command button at present, and it works weel.

    I now want to be able to have it happen at a particular time, probably when i am at home watching the Olympics :-)

    Can someone briefly explain the concepts behind the Timer Event? I can set the given time, but i'm not sure how to get my program to check what the time is. In Access, i have to get my code to check the time every 30 minutes or so and compare it to the required time, but isn't this using resources? If i want to backup at say, 23:00, do i have to get my VB app to check the time every minute? Doesn't this mean that the app is grabbing resources almost constantly? I think you get the gist of my ignorance.

    Many thanks

    Peter Gidden

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Code:
    Dim strTime as String
    Private Sub Timer1_Timer ()
    strTime = Time
    if strTime = TheTimeThatYouWant then
    'code for backing up
    End If
    Set your timers interval to 1000
    NXSupport - Your one-stop source for computer help

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Manchester, England.
    Posts
    18
    Thanks Dimava

    So is this the standard way of doing things? I presume it must be low on resources, cos this will mean the app is checking the time every minute of the day until the stored time.

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Peter,

    Actually the code that Dimava posted will check once each second. The Timer is set using milliseconds. 1000 milliseconds = 1 second.

    The Timer interval can go up to 65535 milliseconds, so if you want to you can set the interval to 60000 to check the time once each minute.

    I am no expert on operating systems, but as far as using up resources, I do not think that a timer running in the background will cause any significant performance hit.

    Your operating system is constantly updating system timers in the background hundreds, if not thousands of times each second anyway. So your program jumping in once each second is just another of numerous processes that are occurring.

  5. #5
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Hi Peter,

    the above code looks for time to reach at every SECOND !!! I think you should be awared that the time interval you set in your timer can't be more than 65535 and that this this interval is in milliseconds...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Manchester, England.
    Posts
    18
    Thanks Guys

    So 60000 = 1 minute which should do fine.

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