9
A
回答
13
事实上定时器功能让你秒,毫秒。返回值的整数部分的秒数,因为午夜的小数部分可以转化成毫秒 - 1000。
t = Timer
' Int() behaves exacly like Floor() function, ie. it returns the biggest integer lower than function's argument
temp = Int(t)
Miliseconds = Int((t-temp) * 1000)
Seconds = temp mod 60
temp = Int(temp/60)
Minutes = temp mod 60
Hours = Int(temp/60)
WScript.Echo Hours, Minutes, Seconds, Miliseconds
' Let's format it
strTime = String(2 - Len(Hours), "0") & Hours & ":"
strTime = strTime & String(2 - Len(Minutes), "0") & Minutes & ":"
strTime = strTime & String(2 - Len(Seconds), "0") & Seconds & "."
strTime = strTime & String(4 - Len(Miliseconds), "0") & Miliseconds
WScript.Echo strTime
1
大厦在MBU的回答只是相乘,这里是一个子版本。在你的代码周围向即时窗口中的消息洒上呼叫,以便你可以看到延迟发生的位置。
' *** Debug.Print the time with milliseconds, and a message of your choice
Private Sub DebugPrintTime(strWhereFrom As String)
On Error GoTo ErrHandler
Dim sglTimer As Single
Dim sglWholeSecs As Single
Dim Millisecs As Variant ' as a variant, Len() will give the length of string representation of this value
Dim Seconds As Variant
Dim Minutes As Variant
Dim Hours As Variant
Dim strTime As String
sglTimer = timer
sglWholeSecs = Int(sglTimer)
Millisecs = Int((sglTimer - sglWholeSecs) * 1000)
Seconds = sglWholeSecs Mod 60
sglWholeSecs = Int(sglWholeSecs/60)
Minutes = sglWholeSecs Mod 60
Hours = Int(sglWholeSecs/60)
strTime = String(2 - Len(Hours), "0") & Hours & ":"
strTime = strTime & String(2 - Len(Minutes), "0") & Minutes & ":"
strTime = strTime & String(2 - Len(Seconds), "0") & Seconds & "."
strTime = strTime & String(3 - Len(Millisecs), "0") & Millisecs
Debug.Print strTime, strWhereFrom
Exit Sub
ErrHandler:
MsgBox "Error in Sub DebugPrintTime" & vbCrLf & Err.Description & vbCrLf & strWhereFrom
Err.Clear
End Sub
相关问题
- 1. 使用Powershell查找时间(以毫秒为单位)?
- 2. Mongodb时间戳,以毫秒为单位
- 3. 时间以毫秒为单位计算
- 4. 花费时间以毫秒为单位
- 5. 如何查找两次之间的时间间隔(以毫秒为单位)?
- 6. 使用boost :: date_time库格式化时间以毫秒为单位
- 7. 使用本地存储需要时间以毫秒为单位
- 8. NetStream.seek以毫秒为单位
- 9. 转换“时间”,“单位”,以毫秒为单位
- 10. 以毫秒为单位的TImespan,以分钟和秒为单位
- 11. 时间选择器以毫秒为单位以毫秒为单位计算出错误的值
- 12. TimePicker以毫秒为单位倒计时
- 13. R 2列之间的时间差(以毫秒为单位)
- 14. 来自BPM(Midi tempo)的时间间隔(以毫秒为单位)
- 15. 如何从两个日期时间戳字段使用ruby查找时间差(以毫秒为单位)
- 16. Linux命令获取以毫秒为单位的时间
- 17. 以毫秒为单位的日期时间选取器
- 18. 以毫秒为单位获取ViewPager视图的时间
- 19. 以毫秒为单位解析Perl的时间戳
- 20. 获取C中的当前时间(以毫秒为单位)?
- 21. 以毫秒为单位的UTC时间到UTC格式
- 22. 以毫秒为单位的减法时间
- 23. AS3让“时间”以毫秒为单位的MP3
- 24. 以毫秒为单位的mp3长度
- 25. Javascript:以毫秒为单位的日期
- 26. Javascript以毫秒为单位显示毫秒数:小时:无秒数分钟
- 27. 矩不正确地分析时间以毫秒为单位
- 28. v $ session_longops TIMESTAMP字段和时间进程以毫秒为单位
- 29. 经过时间以毫秒为单位不同日期
- 30. 从日期获取时间(以毫秒为单位)