[ 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
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 :-)
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