我试图制定简单的方案,将第二代时间转换为h:mm:s Format。 但对某些特定投入价值而言,它会产生一种不正确的时间格式。 这是我尝试的:
Public Class Form1
Dim Hours, Minutes, Seconds As Integer
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
lblHours.Text = "00"
lblMinutes.Text = "00"
lblSeconds.Text = "00"
txtTimeSeconds.Text = ""
txtFormattedTime.Text = ""
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate1.Click
Seconds = Integer.Parse(txtTimeSeconds.Text)
Hours = Seconds / 3600
Seconds = Seconds Mod 3600
Minutes = Seconds / 60
Seconds = Seconds Mod 60
lblHours.Text = Hours.ToString.PadLeft(2, "0"c)
lblMinutes.Text = Minutes.ToString.PadLeft(2, "0"c)
lblSeconds.Text = Seconds.ToString.PadLeft(2, "0"c)
txtFormattedTime.Text = Hours.ToString.PadLeft(2, "0"c) & ":" & Minutes.ToString.PadLeft(2, "0"c) & ":" & Seconds.ToString.PadLeft(2, "0"c)
End Sub
End Class
在投入价值为30时,它就发挥了作用:
在投入价值为31时,它并不发挥作用:
我做了哪些错误? 我如何解决这一问题?