Results 1 to 7 of 7

Thread: [RESOLVED] How to stop timer automatically

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    5

    Resolved [RESOLVED] How to stop timer automatically

    Hello Everyone,

    I am developing a application in which i need your little help to complete...

    i have listbox and have set timer for auto selecting...

    i want to stop the timer after selection in liatbox reaches 10...or you can say that after running that timer 10 times....

    and after 15 min i wanna that turn on automatically....

    finally what i want is :

    a timer stops for 15 minutes after running 10 times ..

    little help would be appreciated..

    thanks in advance.

  2. #2
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: How to stop timer automatically

    Stopping the timer after filling the listbox is easy ... you just monitor the count of items in the listbox in the timer code - when it reaches 10, you set the Timer's .Enabled property to false.

    If you want it to turn on the timer after 15 minutes you'll need a 2nd timer that is enabled at the same time as you disable the first one.

    When your form loads, set Timer1.Enabled = true, Timer2.Enabled = false. Then, when the code in timer1 determines the listbox is filled, disable Timer1, enable timer2. Timer2 should then count to 15 minutes (however you decide to handle that) then re-enable timer1 and disable itself after re-enabling timer1. Lather, rinse, repeat.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    5

    Re: How to stop timer automatically

    Hello sir,,,

    i got it what u say.....but can u give me the code how to stop after 10 counts..plz..

    thanks for ur reply

  4. #4
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: How to stop timer automatically

    Quote Originally Posted by Sumit4Work View Post
    Hello sir,,,

    i got it what u say.....but can u give me the code how to stop after 10 counts..plz..

    thanks for ur reply
    Here's an alternate idea. Why don't you write some code (give it a try) then let us help you debug it. You won't learn anything if I just "give" you the code.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  5. #5
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: How to stop timer automatically

    Place a global variable and initialize it to 0. Everytime the TimerTick event is triggered increment your variable by one. Check to see if it reaches 10 and do what Max suggested then
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    5

    Re: How to stop timer automatically

    thanks max..i got it...

    i made a label and counts the timer...and then use if label value is # then timer2.start and timer1.stop..

    thank you very much sir...

  7. #7
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: How to stop timer automatically

    Quote Originally Posted by Sumit4Work View Post
    thanks max..i got it...

    i made a label and counts the timer...and then use if label value is # then timer2.start and timer1.stop..

    thank you very much sir...
    That's the spirit. Glad you worked it out.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

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