Aftelling

Status
Niet open voor verdere reacties.

nicoOos

Gebruiker
Lid geworden
15 dec 2009
Berichten
7
Wanneer ik op een opdracht knop wordt er in een label van 5 naar 0 geteld:
Private Sub cmdGO_Click()
Dim PauseTime, Start
PauseTime = 5
Start = Timer
Do While Timer <= Start + PauseTime
Label1.Caption = Math.Round((Start + PauseTime + 0) - Timer)
DoEvents
Loop
end if


wat moet je erbij zetten als je de teller automatisch terug naar 5 wilt en vanzelf begint af te tellen?
 
Laatst bewerkt:
nicoOos,

Zet dit eens onder Loop.
Code:
cmdGo_Click

Misschien kun je hier nog wat uit halen, gevonden op het www
Code:
Re: Countdown Timer.
Posted by Geoffrey Hurst on October 23, 2001 1:26 AM

Put this in the Sheet module :-
Private Sub CommandButton1_Click()
Call Timer
End Sub

Put these in a normal module :-
Dim CountDown As Date
Sub Timer()
CountDown = Now + TimeValue("00:00:01")
Application.OnTime CountDown, "Reset"
End Sub
Sub Reset()
Dim count As Range
Set count = [A1] ' A1 contains the number of seconds for the countdown.
count.Value = count.Value - 1
If count <= 0 Then
MsgBox "Countdown complete."
Exit Sub
End If
Call Timer
End Sub
Sub DisableTimer()
On Error Resume Next
Application.OnTime EarliestTime:=CountDown, Procedure:="Reset", Schedule:=False
End Sub

Put this in the Worbook module :-
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DisableTimer
ActiveWorkbook.Saved = True
End Sub
 
Laatst bewerkt:
Dit lijkt mij voldoende in een Macromodule:

Code:
Sub nieuw()
  Blad1.Label1.Caption = IIf(Blad1.Label1.Caption = "1", "5", Format(Val(Blad1.Label1.Caption) - 1))
  Application.OnTime DateAdd("s", 5, Now), "nieuw"
End Sub
 
Bedankt Mijn probleem is opgelost!!! Nu kan ik verder werken
:thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan