
回答会自动过滤缩进,需要按照上图调整语法缩进,下方是代码
import time
countdown_time = 20
# 开始循环
while countdown_time >0:
# 打印当前倒计时时间
print(countdown_time)
# 等待 1 秒
time.sleep(1)
# 倒计时时间减 1
countdown_time -= 1
# 倒计时结束
print("倒计时结束!")
Dim Ts As Integer, Tm As Integer, Th As IntegerDim StartT As Boolean
Private Sub Command1_Click()
If StartT = False Then
Command1.Caption = "暂停时间"
Else
Command1.Caption = "启动时间"
End If
StartT = Not StartT
End Sub
Private Sub Command2_Click()
StartT = False
Command1.Caption = "启动时间"
Ts = 0
Tm = 0
Th = 0
End Sub
Private Sub Command3_Click()
Th = Val(InputBox("输入小时"))
Tm = Val(InputBox("输入分钟"))
Ts = Val(InputBox("输入秒"))
End Sub
Private Sub Form_Load()
Command1.Caption = "启动时间"
Command2.Caption = "停止"
Command3.Caption = "设置时间"
Label1.Caption = "0:00:00"
Timer1.Enabled = True
Timer1.Interval = 1000
Ts = 0
Tm = 0
Th = 0
StartT = False
End Sub
Private Sub Timer1_Timer()
If StartT = True Then
Ts = Ts - 1
If Ts = -1 Then
Ts = 59
Tm = Tm - 1
If Tm = -1 Then
Tm = 59
Th = Th - 1
End If
End If
If Th = 0 And Tm = 0 And Ts = 0 Then
StartT = False
End If
End If
Label1.Caption = Th &":" &Format(Tm, "00") &":" &Format(Ts, "00")
End Sub
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)