Results 1 to 3 of 3

Thread: [ T I M E R C O N T R O L ! ] - help ??

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    5

    Question [ T I M E R C O N T R O L ! ] - help ??

    hi!~ im doing this for school ...for my game.. and im trying to make my timer .. to count backwards (10, 9, 8, 7, 6,5,4,..) etc

    it involves a command button and a timer control . ~ when i try to do it.. nothing happens.. please help me (im still a beginner >_<")

    thank you~~


    Private Sub CmdSolve_Click()
    CountdownTimer.Interval = 1
    CountdownTimer.Enabled = True
    CountdownTimer = 1000
    End Sub

    Private Sub CountdownTimer_Timer()
    Dim ElapsedTime As Integer
    ElaspedTime = 5000
    ElapsedTime = ElapsedTime - CountdownTimer.Interval
    LblTimer.Caption = ElapsedTime
    If ElapsedTime = 0 Then
    MsgBox ("Your Time has expired. Thank you for playing.")
    End If
    End Sub


    Private Sub Form_Load()
    CountdownTimer.Enabled = False
    End Sub
    Last edited by KaraMelLow; Aug 18th, 2006 at 05:28 AM.

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [ T I M E R C O N T R O L ! ] - help ??

    VB Code:
    1. Private Sub CmdSolve_Click()
    2. CountdownTimer.Interval = 1000
    3. CountdownTimer.Enabled = True
    4. End Sub
    5.  
    6. Private Sub CountdownTimer_Timer()
    7. Dim ElapsedTime As Integer
    8. ElaspedTime = 5000
    9. ElapsedTime = ElapsedTime - 1
    10. LblTimer.Caption = ElapsedTime
    11. If ElapsedTime = 0 Then
    12. MsgBox ("Your Time has expired. Thank you for playing.")
    13. End If
    14. End Sub
    15.  
    16. Private Sub Form_Load()
    17. CountdownTimer.Enabled = False
    18. End Sub

    interval uses milliseconds, not seconds...so for each 1 second you put 1000 up to 60000 (or something around there)...that code should work

    Although your problem might be that you have "ElaspedTime = 5000" in the code at the same point as the reduction...so I am guessing it'll always say 4999 :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: [ T I M E R C O N T R O L ! ] - help ??

    A few fixes:
    VB Code:
    1. Dim iSeconds As Integer
    2.  
    3. Private Sub CmdSolve_Click()
    4.  
    5.   iSeconds = 5
    6.   lblTimer.Caption = iSeconds
    7.   CountdownTimer.Interval = 1000
    8.   CountdownTimer.Enabled = True
    9.  
    10. End Sub
    11.  
    12. Private Sub CountdownTimer_Timer()
    13.  
    14.   iSeconds = iSeconds - 1
    15.   lblTimer.Caption = iSeconds
    16.   If iSeconds = 0 Then
    17.     MsgBox ("Your Time has expired. Thank you for playing.")
    18.     CountdownTimer.Enabled = False
    19.   End If
    20.  
    21. End Sub
    22.  
    23. Private Sub Form_Load()
    24. CountdownTimer.Enabled = False
    25. End Sub
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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