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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopwatch Program is Messed Up 1

Status
Not open for further replies.

Boxster1987

Programmer
Aug 9, 2002
19
0
0
US
I'm making a stopwatch program but when the timer gets to 30 seconds, it says 00:29, 01:31, 01:32.... Does anyone know what is wrong?

Here is the code that I wrote:

Dim totalsec As Integer_________________

Private Sub Timer1_Timer()
totalsec = totalsec + 1
minutes = Format(totalsec / 60, "00")
seconds = Format(totalsec Mod 60, "00")
Label1.Caption = minutes & ":" & seconds
End Sub

Please Help!!!
Thanks
 
Yes / (division) rounds so anything over .5 will always round up.

the \ operator divides two numbers and returns only the integer portion of the result.

On a side note you stop watch program will not be accurate.

If you set the timer to go off every second and something on your computer slows it down then you will loose time. ie over a minute your timer should fire 60 times but may only fire 59, 58,... depends on what else is going on. Timers only sit in the message que once so if there is a timer event already waiting to processes when the next one fires off the next one will not be placed in the message que
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top