书上有个例子:秒表计时程序
开始时间:15:03:01
结束时间:15:04:12
经过时间:00:01:11 <---label6书上是这样表示这个经过时间的。感觉这样很麻烦,还有很好的方法吗?Private Sub Timer1_Timer()
......
Dim iHour As Integer, iMinute As Integer, iSecond As Integer
Dim vTime As Variant
iHour = Hour(CDate(Label5.Caption)) - Hour(CDate(Label4.Caption))
iMinute = Minute(CDate(Label5.Caption)) - Minute(CDate(Label4.Caption))
iSecond = Second(CDate(Label5.Caption)) - Second(CDate(Label4.Caption))
vTime = TimeSerial(iHour, iMinute, iSecond)
Label6.Caption = Format(vTime, "hh:mm:ss")......
End Sub
开始时间:15:03:01
结束时间:15:04:12
经过时间:00:01:11 <---label6书上是这样表示这个经过时间的。感觉这样很麻烦,还有很好的方法吗?Private Sub Timer1_Timer()
......
Dim iHour As Integer, iMinute As Integer, iSecond As Integer
Dim vTime As Variant
iHour = Hour(CDate(Label5.Caption)) - Hour(CDate(Label4.Caption))
iMinute = Minute(CDate(Label5.Caption)) - Minute(CDate(Label4.Caption))
iSecond = Second(CDate(Label5.Caption)) - Second(CDate(Label4.Caption))
vTime = TimeSerial(iHour, iMinute, iSecond)
Label6.Caption = Format(vTime, "hh:mm:ss")......
End Sub
label6=format(cdate(label5)-cdate(label4),"hh:mm:ss")
我都试了一下
label6=format(cdate(label5)-cdate(label4),"hh:mm:ss") 和下面的
label6.caption=format(cdate(label5.caption)-cdate(label4.caption),"hh:mm:ss")
都是可以的,但下面的更规范些。