使用Timer控件制作倒计时程序,设计时界面如下图所示。 设计时界面 程序运行时,用户在文本框中输入分钟数
1个回答
展开全部
'试一下,给你用秒演示,自己修改
Option Explicit
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
If IsNumeric(Text1) Then
Text1 = 60 * Val(Text1) '化为秒,给你用分钟数演示
Command1.Caption = "结束"
Timer1.Interval = 1000
End If
Else
Command1.Caption = "开始"
Timer1.Interval = 0
If Text1 <> 0 Then Text1 = Text1 / 60
End If
End Sub
Private Sub Form_Load()
Frame1.Caption = "请输入倒计时的分钟数"
Text1 = ""
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
If Command1.Caption = "开始" Then Exit Sub
Text1 = Text1 - 1
If Text1 <= 0 Then
Timer1.Interval = 0
Command1.Caption = "开始"
End If
End Sub
Option Explicit
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
If IsNumeric(Text1) Then
Text1 = 60 * Val(Text1) '化为秒,给你用分钟数演示
Command1.Caption = "结束"
Timer1.Interval = 1000
End If
Else
Command1.Caption = "开始"
Timer1.Interval = 0
If Text1 <> 0 Then Text1 = Text1 / 60
End If
End Sub
Private Sub Form_Load()
Frame1.Caption = "请输入倒计时的分钟数"
Text1 = ""
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
If Command1.Caption = "开始" Then Exit Sub
Text1 = Text1 - 1
If Text1 <= 0 Then
Timer1.Interval = 0
Command1.Caption = "开始"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询