VB基础问题:如果做秒表!
2个回答
展开全部
一个command 一个label 一个timer
timer的interval设置为100.
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim StartT As Long
Private Sub Command1_Click()
StartT = GetTickCount
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Dim EndT As Long
EndT = GetTickCount
Label1.Caption = Abs(StartT - EndT) / 1000 & " Seconds Passed."
End Sub
'用gettickcount防止CPU占用过高时timer停止计时的错误
timer的interval设置为100.
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim StartT As Long
Private Sub Command1_Click()
StartT = GetTickCount
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Dim EndT As Long
EndT = GetTickCount
Label1.Caption = Abs(StartT - EndT) / 1000 & " Seconds Passed."
End Sub
'用gettickcount防止CPU占用过高时timer停止计时的错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询