设计一个倒计时程序,用户在倒计时文本框中输入倒计时的分钟数,按F1键开始倒计时。
1个回答
展开全部
Dim i As Integer
Dim a As Double
Dim h, m, s As Integer
Dim T As Double
Private Function TimeDisPlay(n As Double) As String '显示时钟函数
Dim h, m, s As Integer
Dim i As Integer
h = Int(n / 3600)
m = Int((n Mod 3600) / 60)
s = n Mod 60
TimeDisPlay = Format(CStr(h), "00") & ":" & Format(CStr(m), "00") & ":" & Format(CStr(s), "00")
End Function
Private Sub Command1_Click()
a = InputBox("清输入定时分钟数")
T = a * 60 '换算为秒
End Sub
Private Sub Command2_Click()
Slider1.Min = 0
Slider1.Max = T
Timer1.Enabled = True
Timer1.Interval = 1000 '设置计时器为1秒运行一次
End Sub
Private Sub Form_Load()
Slider1.Max = 100
Slider1.Min = 0
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Text1.Text = TimeDisPlay(T)
T = T - 1
i = i + 1
Slider1.Value = i
If T = 0 Then
Timer1.Enabled = False
MsgBox ("倒计时结束!")
End If
End Sub
Dim a As Double
Dim h, m, s As Integer
Dim T As Double
Private Function TimeDisPlay(n As Double) As String '显示时钟函数
Dim h, m, s As Integer
Dim i As Integer
h = Int(n / 3600)
m = Int((n Mod 3600) / 60)
s = n Mod 60
TimeDisPlay = Format(CStr(h), "00") & ":" & Format(CStr(m), "00") & ":" & Format(CStr(s), "00")
End Function
Private Sub Command1_Click()
a = InputBox("清输入定时分钟数")
T = a * 60 '换算为秒
End Sub
Private Sub Command2_Click()
Slider1.Min = 0
Slider1.Max = T
Timer1.Enabled = True
Timer1.Interval = 1000 '设置计时器为1秒运行一次
End Sub
Private Sub Form_Load()
Slider1.Max = 100
Slider1.Min = 0
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Text1.Text = TimeDisPlay(T)
T = T - 1
i = i + 1
Slider1.Value = i
If T = 0 Then
Timer1.Enabled = False
MsgBox ("倒计时结束!")
End If
End Sub
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询