VBA-显示时钟时间,精度不到一秒

All*_*owe 3 excel vba excel-vba

有没有一种方法可以使用VBA(excel)生成精确到十分之一秒或更短的时钟时间?

例如:

Sub test()
    MsgBox Format(Time, "hh:mm:ss???") 'not sure what this format should be...
End Sub
Run Code Online (Sandbox Code Playgroud)

Nic*_*kis 5

我认为这Time不能提供该信息。

您可以使用Timer以获得更高的准确性。

在Microsoft Windows中,Timer函数返回秒的小数部分。在Macintosh上,计时器分辨率为一秒。

这是一个例子:

MsgBox Format(Time, "hh:mm:ss:" & Right(Format(Timer, "#0.00"), 2))
Run Code Online (Sandbox Code Playgroud)

  • Format(Now(),"ms") 会给你时间的毫秒部分,但它不是很准确。 (4认同)