Results 1 to 7 of 7

Thread: Timer

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    3

    Question Timer

    I am making a game show type of game and i dont know how to make a timer on it so that there is a label that is shrinking in size untill it is gone. When it is gone i am going to make form2.visible=false. So if u have a code that can make this type of timer please post a reply
    thanks,
    sniper

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Place a Timer on your form and call it TmrLabel then add this code:
    VB Code:
    1. Private Sub TmrLabel_Timer()
    2. Static Times As Integer
    3.    
    4.     If Times = 10 Then ' Change 10 to the amount of steps you want!
    5.         'Hide the other form...
    6.         Form2.Visible = False
    7.        
    8.         'Disable the Timer...
    9.         TmrLabel.Enabled = False
    10.        
    11.         'Set Times to zero so it can be run again...
    12.         Times = 0
    13.     Else
    14.         'Do the code to make the label smaller...
    15.        
    16.        
    17.         'Increment the counter...
    18.         Times = Times + 1
    19.     End If
    20. End Sub
    Hope that helps you, I didn't do the code for shrinking the label because I wasn't sure how your going about that .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    3

    timer shrinking

    what i mean by the timer shrinking is that it will be like a label box that is a long rectangle and as the time runs out the rectangle will get shorter.

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: timer shrinking

    Posted by sniper_014
    what i mean by the timer shrinking is that it will be like a label box that is a long rectangle and as the time runs out the rectangle will get shorter.
    Your going to be changing the font to do that right?

    You will still be able to use my code, the total time until the time runs out will be 10 * TmrLabel.Interval (where the 10 is you can chage this to add more time), the interval will simply determine how acurate it is, so if you make the interval smaller then it will be smooth but if you make it big it will be jumpy. Whenever you change the interval remember it will effect the total time so you'll need to then edit the 10 .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    If you put this line where I left a spare then it works but I don't know how you want it to shrink. If it would shink into the center (which is a bit harder) or like this line does makes it shrink into the top left corner :
    VB Code:
    1. Label1.Font.Size = Label1.Font.Size - 2
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  6. #6
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    I really would consider using a set of functions based on GetTickCount() instead of the normal VB timers, you can save a lot of resources by doing that ...
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  7. #7
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    Place a timer on the form, give it an interval of 10. Put your label, double click the timer, and in the event make the label shrink relative to itself.

    ...cooties? over the internet?
    Don't pay attention to this signature, it's contradictory.

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