
用vb设计一个简单的计时器代码怎么写?
3个回答
展开全部
'添加一个Timer1,一个Command1,一个Label1
Dim H As Integer, M As Integer, S As Integer
Private Sub Command1_Click()
Timer1.Interval = 0
MsgBox H & " 小时 " & M & " 分钟 " & S & " 秒 "
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
S = 0
M = 0
H = 0
Label1.Caption = Format(H, "00") & ":" & Format(M, "00") & ":" & Format(S, "00")
End Sub
Private Sub Timer1_Timer()
S = S + 1
If S > 60 Then
M = M + 1
End If
If M > 60 Then
H = H + 1
End If
Label1.Caption = Format(H, "00") & ":" & Format(M, "00") & ":" & Format(S, "00")
End Sub
Dim H As Integer, M As Integer, S As Integer
Private Sub Command1_Click()
Timer1.Interval = 0
MsgBox H & " 小时 " & M & " 分钟 " & S & " 秒 "
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
S = 0
M = 0
H = 0
Label1.Caption = Format(H, "00") & ":" & Format(M, "00") & ":" & Format(S, "00")
End Sub
Private Sub Timer1_Timer()
S = S + 1
If S > 60 Then
M = M + 1
End If
If M > 60 Then
H = H + 1
End If
Label1.Caption = Format(H, "00") & ":" & Format(M, "00") & ":" & Format(S, "00")
End Sub
展开全部
需要利用timer控件,打开计时器时把控件里的时间附一个值给a然后计时结束时候再付另一个值给b,最后b-a(转换下)就出来了吧?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
以前上学的时候写过,搜一搜,应该有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询