"ss" 格式的数字大于 60

Having number above 60 in "ss" format

Global time As Date

Sub countdown()
time = Now()
time = DateAdd("s", 120, time)

Do Until time < Now()
DoEvents
oSh.TextFrame.TextRange = Format((time - Now()), "ss")
Loop
End Sub

计时器从60开始,到00结束。然后重复同样的事情。是否可以直接从 120 启动定时器?我们该怎么办?

Format 只会从日期值中读取秒数,无法“强制”它计算总秒数。不过手动计算还是比较容易的:

Dim delta as Date
delta = t - now
oSh.TextFrame.TextRange = Minute(d) * 60 + Second(d)
' or, if you want to have always 3 digits, eg 030
oSh.TextFrame.TextRange = Format(Minute(d) * 60 + Second(d), "000")

使用DateDiff:

Global StopTime As Date

Sub countdown()

    StopTime = DateAdd("s", 120, Now)

    Do Until StopTime < Now
        DoEvents
        oSh.TextFrame.TextRange = DateDiff("s", Now, StopTime)
    Loop

End Sub