用VB编写一个程序利用计时器计时,在窗体上添加四个命令按钮,一个标签,一个计时器控件,注意:在Timer的事
发布网友
发布时间:2023-04-21 15:15
我来回答
共4个回答
热心网友
时间:2023-10-16 04:54
界面你自己设计 代码我帮你写 等一下附上来
------------------------------------
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
热心网友
时间:2023-10-16 04:54
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
热心网友
时间:2023-10-16 04:54
因为你弄成form.load事件了
热心网友
时间:2023-10-16 04:55
问题不明确 可以再说详细点吗?