Results 1 to 9 of 9

Thread: timer

  1. #1

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474

    timer

    How can i put a timer between events .. I mean . If the program is dont processing a line then i want it to wait for 3 seconds and then start processing again .

  2. #2
    That sounds like multithreading. Can you be more clear? Do you mean you just want your program to do nothing for 3 seconds, or allow other parts of your program to execute for 3 seconds while the other part waits?

  3. #3
    Addicted Member reznor's Avatar
    Join Date
    May 2001
    Location
    Netherlands
    Posts
    151
    Use the sleep Api
    Code:
    Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
    Use it like this:
    Sleep(3000) 'for 3 seconds
    "Computers are incredibly fast, accurate and stupid. Human beings are incredibly slow, inaccurate and brilliant. Together they are powerful beyond imagination." - Albert Einstein

  4. #4

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    well the other parts are alredy executing ..

    Well may be there is an easier way to do it ... But cause i am new to VB so i dont know all the shorcuts ... I want a lable to flash ..
    I am using it kind of like a process indicator ....

    so i want to use a timer so that it flashes every second or something..
    I hope you understand what i am saying

  5. #5
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Set the timer.enabeled = false when you start processing and when it's done processing to timer.enabeled = true this will do the trick i think

    Grtz,

    Bloged

  6. #6
    Addicted Member
    Join Date
    Jul 2001
    Location
    Germany, BW
    Posts
    157

    Lightbulb idea ? ..

    hy,
    try this ... probably ...

    code:
    ----------------

    'Your timer interval must be 3000

    Private Sub Timer1_Timer ()

    'Your command ...

    Timer1.Interval = 0
    Timer2.Interval = 3000
    End Sub

    Private Sub Timer2_Timer ()

    'Your command ...

    Timer1.Interval = 3000
    Timer2.Interval = 0
    End Sub

    ------------------
    and so it works:

    timer1 is running 3 sek until your command is executed
    after your command is exec the timerinterval is set to 0
    then this timer (timer1) is "shut down"
    --> now timer2's interval is set to 3 sek ... after 3 sek (tim2) the same procedure starts again

    Longbow

    hope you understand ...
    Old enough to know better,
    but young enough to don't give a ****!

  7. #7
    But if you want the label to flash at a constant rate, you can't necessarily rely on a timer. You may want to try multithreading. ...But if you are newish to VB or the concept of threads, just use the timer.

  8. #8

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474
    Well i am not really that new to VB .. and i do have the concept about multi threads .. but unfortunately i never really got to use it ... But i think that it should be soemthing interesting to learn ...

  9. #9
    Interesting doesn't begin to describe it.

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