我正在启动小时、分钟和秒
然后将其转换为总毫秒数。
然后我正在做的是从 Elapsed MilliSeconds 中减去 Total MilliSeconds
IEelms = cms - e.Milliseconds
(评估的毫秒 = 计算的毫秒。- Stopwatch.elapsedMilliseconds)
然后将评估的毫秒转换回 HH:MM:SS:MS 格式。
但由于一些逻辑错误,它无法正常工作,这就是为什么我需要一些帮助。请帮帮我这是我的代码:
Dim dd As Integer = 0
Dim mm As Integer = 0
Dim hh As Integer = 0
Dim ss As Integer = 0
Dim ms As Integer = 0
Dim cms As Long = 0
Dim elms As Long = 0
Dim stopwatch As System.Diagnostics.Stopwatch = New System.Diagnostics.Stopwatch
Dim dt As DispatcherTimer = New DispatcherTimer
Private Sub StartButton_Click(sender As Object, e As RoutedEventArgs) Handles StartButton.Click
hh = Hours.Text * 60 * 60 * 1000
mm = Minutes.Text * 60 * 1000
ss = Seconds.Text * 1000
cms = hh + mm + ss
hh = mm = ss = 0
Start()
End Sub
Private Sub Start()
dt.Interval = New TimeSpan(0, 0, 0, 0, 10)
AddHandler dt.Tick, AddressOf ontimertick
stopwatch.Start()
dt.Start()
End If
End Sub
Private Sub ontimertick()
Dim e As New TimeSpan
e = stopwatch.Elapsed
elms = cms - e.Milliseconds
ss = ((elms Mod (1000 * 60 * 60)) Mod (1000 * 60)) \ 1000
mm = (elms Mod (1000 * 60 * 60)) \ (1000 * 60)
hh = elms \ (1000 * 60 * 60)
elms = elms Mod 1000
MicroSeconds.Text = elms.ToString("00")
Seconds.Text = ss.ToString("00")
Minutes.Text = mm.ToString("00")
Hours.Text = hh.ToString("00")
End Sub