Re: [RE-OPEN] [RESOLVED] Stop Watch
Hi! I re-open this thread because I am having trouble with the timer the first time I will run the program, the timer runs fast specifically the timing from 1 second to 2 seconds....but if I will run it again the problem is not occuring....but if I will close the program and then re-run it by then the same problem occurs.....why is this so?
Here's my code so far.
Code:
Private Watch As New Diagnostics.Stopwatch
Private nextSoundTime As Date = DateTime.Now.AddSeconds(1)
Dim AutoStop As Integer
Private Sub FrmStopWatch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Timer1.Interval = 100 '1/10 of a second
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Elapsed = Me.Watch.Elapsed
'Dim AutoStop As Integer
'show the stopwatch elapsed time
Me.lbltime.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:0}", _
Elapsed.TotalHours, Elapsed.Minutes, Elapsed.Seconds, Elapsed.Milliseconds \ 100)
'check autostep seconds if empty, if yes don't play sound
If Not (txtAutoStop.Text = String.Empty) AndAlso (Integer.TryParse(txtAutoStop.Text, AutoStop)) Then
If DateTime.Now >= Me.nextSoundTime Then
My.Computer.Audio.Play(My.Resources.BIP, AudioPlayMode.Background)
Me.nextSoundTime = Me.nextSoundTime.AddSeconds(1)
End If
End If
'check autostep seconds
If Not (txtAutoStop.Text = String.Empty) AndAlso (Integer.TryParse(txtAutoStop.Text, AutoStop)) Then
If Watch.ElapsedMilliseconds \ 1000 >= AutoStop Then
btnStop.PerformClick()
My.Computer.Audio.Play(My.Resources.Piano_PAd_glissando_descend_BLASTWAVEFX_06741, AudioPlayMode.Background)
btnReset.Focus()
End If
Else
txtAutoStop.Text = String.Empty
End If
End Sub
Re: [RE-OPEN] [RESOLVED] Stop Watch
anyone who has idea why this is happening? does it have something to do with the computer I am using?
I am using intel core 2 duo HP pavilion with 4GB RAM.