VB程序中,用定时器timer制作一个秒表,当按下开始时,标签从0开始,每隔一秒加1,按下停止,停
VB程序中,用定时器timer制作一个秒表,当按下开始时,标签从0开始,每隔一秒加1,按下停止,停止计时。按下清零,则标签显示为0,编写程序代码...
VB程序中,用定时器timer制作一个秒表,当按下开始时,标签从0开始,每隔一秒加1,按下停止,停止计时。按下清零,则标签显示为0,编写程序代码
展开
1个回答
展开全部
'Timer属性初始值:
'Enable = False
'Interval = 1000
'Command1为开始/停止按钮,属性初始值:
'Caption = "开始"
'Label1为标签,属性初始值:
'Caption = "0"
Dim LostSecond As Double
Private Sub Command1_Click()
With Command1
If .Caption = "开始" Then .Caption = "停止" Else .Caption = "开始"
End With
LostSecond = CDbl(Now)
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = False Then Label1 = "0"
End Sub
Private Sub Timer1_Timer()
Label1 = Format(CDbl(Now) - LostSecond, "h:mm:ss")
End Sub
'Enable = False
'Interval = 1000
'Command1为开始/停止按钮,属性初始值:
'Caption = "开始"
'Label1为标签,属性初始值:
'Caption = "0"
Dim LostSecond As Double
Private Sub Command1_Click()
With Command1
If .Caption = "开始" Then .Caption = "停止" Else .Caption = "开始"
End With
LostSecond = CDbl(Now)
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = False Then Label1 = "0"
End Sub
Private Sub Timer1_Timer()
Label1 = Format(CDbl(Now) - LostSecond, "h:mm:ss")
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询