|
-
Aug 18th, 2006, 05:25 AM
#1
Thread Starter
New Member
[ 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.
-
Aug 18th, 2006, 05:33 AM
#2
PowerPoster
Re: [ T I M E R C O N T R O L ! ] - help ??
VB Code:
Private Sub CmdSolve_Click()
CountdownTimer.Interval = 1000
CountdownTimer.Enabled = True
End Sub
Private Sub CountdownTimer_Timer()
Dim ElapsedTime As Integer
ElaspedTime = 5000
ElapsedTime = ElapsedTime - 1
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
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.
-
Aug 18th, 2006, 10:08 AM
#3
Re: [ T I M E R C O N T R O L ! ] - help ??
A few fixes:
VB Code:
Dim iSeconds As Integer
Private Sub CmdSolve_Click()
iSeconds = 5
lblTimer.Caption = iSeconds
CountdownTimer.Interval = 1000
CountdownTimer.Enabled = True
End Sub
Private Sub CountdownTimer_Timer()
iSeconds = iSeconds - 1
lblTimer.Caption = iSeconds
If iSeconds = 0 Then
MsgBox ("Your Time has expired. Thank you for playing.")
CountdownTimer.Enabled = False
End If
End Sub
Private Sub Form_Load()
CountdownTimer.Enabled = False
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|