|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
想做一个倒计时的小程序,但是规则在ontime地方不运行,- Dim n1 As Date, n2 As Date, bo As Boolean
- Private Sub textmin_change()
- stext = textmin.Text
- For i = 1 To Len(stext)
- Select Case Mid(stext, i, 1)
- Case "0" To "9"
- Case Else
- stext = Replace(stext, Mid(stext, i, 1), "")
- End Select
- Next
- textmin.Text = stext
- End Sub
- Private Sub texts_change()
- stext = texts.Text
- For i = 1 To Len(stext)
- Select Case Mid(stext, i, 1)
- Case "0" To "9"
- Case Else
- stext = Replace(stext, Mid(stext, i, 1), "")
- End Select
- Next
- texts.Text = stext
- End Sub
- Private Sub 命令_Click()
- If Not bo Then
- Call 计时
- Else
- Call 停止
- End If
- End Sub
- Sub 计时()
- Dim ms As Date
- ms = CDate("00:" & timeshow.Caption)
- n1 = Now + TimeValue("00:00:01")
- n2 = ms - TimeValue("00:00:01")
- bo = True
- If n2 = TimeValue("00:00:00") Then
- Call 停止
- Exit Sub
- End If
- timeshow.Caption = Format(n2, "nn:ss")
- Application.OnTime n1, "计时"
- End Sub
- Sub 停止()
- On Error Resume Next
- bo = False
- Application.OnTime n1, "计时", , False
- End Sub
- Private Sub 重置时间_Click()
- Dim m As Integer, s As Integer, ms As Date
- m = textmin.Text
- s = texts.Text
- ms = TimeSerial(0, m, s)
- timeshow.Caption = Format(ms, "nn:ss")
- bo = False
- End Sub
复制代码 |
|