Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you make a timer/countdown for VB? 1

Status
Not open for further replies.

modo

MIS
Nov 6, 2002
2
0
0
FR
i am a beginner to visual basic 5 and need to know how to make a timer- not the timer in VB but a timer which counts down to zero and then i'll tell VB what to do. If you can help me, please let me know.

Thanks a lot!
 
Justin, a link on a site called Planet SourceCode - the link picks up at 1 0f 414 listings for the word 'timer'. Consider this - you are only in need of a timed event to spawn the next event and not necessarily a count-down.
Happy Hunting!

Viper
 
you could also use the timer control built in vb, and remember the intervals are in milliseconds! Tekno
Wireless Toyz
Ypsilanti, Michigan
 
this example is from VB6 help files

Timer Function Example
This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox &quot;Paused for &quot; & TotalTime & &quot; seconds&quot;
Else
End
End If

 
Hi,
You can try this example and modify it as needbe.

Option Explicit
Dim Secs As Byte

Private Sub Form_Load()
Secs = 60
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
lblTimer = Secs
Secs = Secs - 1
End Sub

 
helo there

a better solution is to use &quot;GetTickCount()&quot; Windows API function and subtract the value from system time to count down.

ComputerJin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top