展开全部
'一个标签,两个按钮,一个计时器。
'标签显示时间,按钮一控制秒表,按钮二清零。
Dim m As Integer, s As Integer, ms As Integer, flag As Boolean
Private Sub Command1_Click()
If flag = False Then
Timer1.Interval = 10
flag = True
Else
Timer1.Interval = 0
flag = False
End If
End Sub
Private Sub Command2_Click()
flag = False
Timer1.Interval = 0
m = 0
s = 0
ms = 0
Label1.Caption = "00:00:00"
End Sub
Private Sub Timer1_Timer()
ms = ms + 1
If ms = 100 Then
s = s + 1
ms = 0
End If
If s = 60 Then
m = m + 1
s = 0
End If
Label1.Caption = Format(m, "00:") & Format(s, "00:") & Format(ms, "00")
End Sub
'标签显示时间,按钮一控制秒表,按钮二清零。
Dim m As Integer, s As Integer, ms As Integer, flag As Boolean
Private Sub Command1_Click()
If flag = False Then
Timer1.Interval = 10
flag = True
Else
Timer1.Interval = 0
flag = False
End If
End Sub
Private Sub Command2_Click()
flag = False
Timer1.Interval = 0
m = 0
s = 0
ms = 0
Label1.Caption = "00:00:00"
End Sub
Private Sub Timer1_Timer()
ms = ms + 1
If ms = 100 Then
s = s + 1
ms = 0
End If
If s = 60 Then
m = m + 1
s = 0
End If
Label1.Caption = Format(m, "00:") & Format(s, "00:") & Format(ms, "00")
End Sub
展开全部
1)
启动visual basic6.0 ,打开一个新的标准工程。
2)
在窗体上Form1上添加6个标签空间(Label) 2个命令按钮(CommandButton)和1个计时器(Timer)。命令按钮的Caption属性分别为“启动”“停止”
Timer1的Interval属性为10
Label1 Label2 Label3的Caption属性分别为“开始时间”“结束时间”“经过时间” Timer1的Enable属性为False
3)代码
Dim Starttime As Variant
Dim End time As Variant
Dim Elapsed As Variant
Private Sub cmdStart_Click()
'显示开始时间
lblStart.Caption=Time$
Starttime=Now
'启动时钟控件
Timer1.Enabled=Ture
End Sub
Private Sub cmdStop_Click()
'记录停止时间
Endtime=Now
'关闭时钟控件
Timer1.Enabled=False
'显示经过时间
lblApaed.Caption=Format(Endtime-Starttime,"hh:mm:ss"
End Sub
Private Sub Timer1_Timer()
lblStop.Caption=Time$
End Sub
以上是用VB6.0实现的
启动visual basic6.0 ,打开一个新的标准工程。
2)
在窗体上Form1上添加6个标签空间(Label) 2个命令按钮(CommandButton)和1个计时器(Timer)。命令按钮的Caption属性分别为“启动”“停止”
Timer1的Interval属性为10
Label1 Label2 Label3的Caption属性分别为“开始时间”“结束时间”“经过时间” Timer1的Enable属性为False
3)代码
Dim Starttime As Variant
Dim End time As Variant
Dim Elapsed As Variant
Private Sub cmdStart_Click()
'显示开始时间
lblStart.Caption=Time$
Starttime=Now
'启动时钟控件
Timer1.Enabled=Ture
End Sub
Private Sub cmdStop_Click()
'记录停止时间
Endtime=Now
'关闭时钟控件
Timer1.Enabled=False
'显示经过时间
lblApaed.Caption=Format(Endtime-Starttime,"hh:mm:ss"
End Sub
Private Sub Timer1_Timer()
lblStop.Caption=Time$
End Sub
以上是用VB6.0实现的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询