Results 1 to 14 of 14

Thread: timer?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    timer?

    i have multiple timers, is there anyway to stop them all at once?, sorry if i sound dumb, i just started VB for school, and we have to make a program for finals.
    Last edited by fallingjazz; Jan 15th, 2005 at 01:49 AM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: timer?

    there are very few times that you actually need to use more than one timer in a project. desribe what you need to do and someone will help you do it without multiple timers.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: timer?

    Quote Originally Posted by dglienna
    there are very few times that you actually need to use more than one timer in a project. desribe what you need to do and someone will help you do it without multiple timers.
    im trying to make a pong game.

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: timer?

    why would you need more than one timer? It could count off minutes, and you could do other things based on the time elapsed.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: timer?

    one timer to hit the padel, one timer to go in the other direction, one timer to send it back. Thats how my teacher told me to do it, so i dont know how else i would go about it.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: timer?

    i agree one timer is enough, but here is the code to turn them all off

    VB Code:
    1. For Each control In Controls
    2.     If TypeOf control Is timer Then control.Enabled = False
    3. Next

    regds pete

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: timer?

    if timer1.timer <= 0 then
    timer1.enabled =false
    timer2.enabled =false
    timer3.enabled =false
    timer4.enabled =false

    i think thats the best way for a beginner
    Last edited by |2eM!x; Jan 15th, 2005 at 02:15 AM.

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: timer?

    except that you have it backwards. that is less than zero, and the timer will always be > zero (greater)

  9. #9
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: timer?

    well i typed it wrong but it should have a textbox
    and the textbox should be minusing so

    text1.text = text1.text - 1
    if text1.text <=0 then
    timer1.enabled =false
    timer2.enabled =false
    timer3.enabled =false
    timer4.enabled =false

    if you dont have the <= to zero, sometimes the timer will skip to -1, and then it will continue to run, so i like the <=

  10. #10

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: timer?

    how would you make pong w/o timers?

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: timer?

    if the ball goes past the left side of the form, then it is out. if the paddle connects at the edge of the form, it goes back. if it goes back and forth 5 times, it speeds up. you could even have it play itself. just move the paddles randomly, and if they connect, great.

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: timer?

    if timer1.timer <= 0 then
    timer1.enabled =false
    timer2.enabled =false
    timer3.enabled =false
    timer4.enabled =false

    i think thats the best way for a beginner

    so how did you know how many timers there were to turn off? no one told me it was 4, if there is more than 4 some won't be turned off, and if less than 4 an error will be generated

    p.

  13. #13
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: timer?

    i read "multiple" as 4 for some reason..damn brain

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: timer?

    I don't remember pong as having a timer. you played until you lost. there was no beating the box.

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