跪求 vb多功能计时器代码 要有时钟 秒表 和倒计时的功能,秒表有暂停,开始功能的

 我来答
chenxfsoft
2011-02-22 · TA获得超过1380个赞
知道大有可为答主
回答量:2418
采纳率:0%
帮助的人:1831万
展开全部
简单的么,用timer控件做,精确些的么用,timer函数做.
时钟和倒计时很简单的了自己做一下
下面是 一个秒表程序,command 3个,label 1个.

Option Explicit

Dim PP As Boolean
Dim SS As Boolean
Dim TT As Single

Private Sub Command1_Click() '开始
TT = 0
PP = False
SS = False
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = True
Command2.Caption = "暂停"

tmr

End Sub

Private Sub tmr() '秒表
Dim t As Single
t = Timer

Do

showTT Timer - t + TT
DoEvents

Loop Until SS Or PP
TT = Timer - t + TT

End Sub
Private Sub showTT(ByVal t As Single)
Dim h As Integer
Dim s As String

h = Int(t / 3600)
t = t - h * 3600
s = h & ":"
h = Int(t / 60)
s = s & Format(h, "00") & ":"
t = t - h * 60
h = Int(t)
s = s & Format(h, "00") & "."
t = Int((t - h) * 100)
s = s & t
Label1.Caption = s

End Sub

Private Sub Command2_Click() '暂停和继续
PP = Not PP
Command2.Caption = IIf(PP, "继续", "暂停")
If Not PP Then tmr

End Sub

Private Sub Command3_Click()
SS = True
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False

End Sub
追问
还要求液晶数字的
来自:求助得到的回答
问问nh
2013-02-07 · TA获得超过1395个赞
知道小有建树答主
回答量:228
采纳率:0%
帮助的人:208万
展开全部
把300改为5,省时间
Dim n1 As Integer
Dim n2 As Integer
Private Sub Command1_Click()
Timer1.Interval = 1000
n1 = 300
n1 = n1 - n2
n2 = n2 + 1
Label1.Caption = Str(n1)
If n1 = 0 Then
Timer1.Enabled = True
n1 = 300: n2 = 0
End If
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 1000
n1 = 300
n2 = n2 + 1
n1 = n1 - n2
Label1.Caption = Str(n1)
If n1 = 0 Then
Call Command1_Click
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式