【发布时间】:2015-10-24 14:56:39
【问题描述】:
我的 VB 程序中有以下代码。我注意到计时器标签将显示时间 59:59 然后 0:00。
我想要的是显示 1:00:00 的计时器,但似乎无法正确显示。
Private Sub tmrShowTimer_Tick(sender As Object, e As EventArgs) Handles tmrShowTimer.Tick
' Timer Event to handle the StopWatch counting the "Show Timer" hopefully this doesn't get too full.
Dim tsShowElapsed As TimeSpan = Me.stwShowTimer.Elapsed
If tsShowElapsed.Hours >= 1 Then
lblShowTimer.Font = New Font(lblShowTimer.Font.Name, 18)
End If
lblShowTimer.Text = String.Format("{1:#0}:{2:00}",
Math.Floor(tsShowElapsed.TotalHours),
tsShowElapsed.Minutes,
tsShowElapsed.Seconds)
End Sub
为了正确格式化我缺少什么?
【问题讨论】:
标签: vb.net string timespan stopwatch