用VB编写一个程序利用计时器计时,在窗体上添加四个命令按钮,一个标签,一个计时器控件,注意:在Timer的事
4个回答
展开全部
界面你自己设计 代码我帮你写 等一下附上来
------------------------------------
Dim s As Integer
Private Sub Command1_Click() '开始按钮
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() '停止按钮
Timer1.Enabled = False
End Sub
Private Sub Command3_Click() '重新计时按钮
s = 0
End Sub
Private Sub Command4_Click() '关闭按钮
End
End Sub
Private Sub Form_Load()
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
s = s + 1
Label1.Caption = s
End Sub
------------------------------------
Dim s As Integer
Private Sub Command1_Click() '开始按钮
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() '停止按钮
Timer1.Enabled = False
End Sub
Private Sub Command3_Click() '重新计时按钮
s = 0
End Sub
Private Sub Command4_Click() '关闭按钮
End
End Sub
Private Sub Form_Load()
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
s = s + 1
Label1.Caption = s
End Sub
追问
为什么,没点开始按钮就开始计时了?
追答
Private Sub Form_Load()
Timer1.Enabled = false '这样就可以了
Label1.Caption = ""
End Sub
展开全部
Dim s As Integer
Private Sub Command1_Click() '开始按钮与暂停继续可省去command2
Timer1.Interval = 1000
If Timer1.Enabled = False Then
Timer1.Enabled = True
ElseIf Timer1.Enabled = True Then
Timer1.Enabled = False
End If
End Sub
Private Sub Command2_Click() '停止按钮
Timer1.Enabled = False
End Sub
Private Sub Command3_Click() '重新计时按钮
Cls
s = 0
End Sub
Private Sub Command4_Click() '关闭按钮
End
End Sub
Private Sub Form_Load()
command1.caption=“开始/暂停/继续”
command3.caption=“重新计时”
Timer1.Enabled = False '这样就可以了
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
s = s + 1
Label1.Caption = s
End Sub
Private Sub Command1_Click() '开始按钮与暂停继续可省去command2
Timer1.Interval = 1000
If Timer1.Enabled = False Then
Timer1.Enabled = True
ElseIf Timer1.Enabled = True Then
Timer1.Enabled = False
End If
End Sub
Private Sub Command2_Click() '停止按钮
Timer1.Enabled = False
End Sub
Private Sub Command3_Click() '重新计时按钮
Cls
s = 0
End Sub
Private Sub Command4_Click() '关闭按钮
End
End Sub
Private Sub Form_Load()
command1.caption=“开始/暂停/继续”
command3.caption=“重新计时”
Timer1.Enabled = False '这样就可以了
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
s = s + 1
Label1.Caption = s
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
因为你弄成form.load事件了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问题不明确 可以再说详细点吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询