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. 使用SPARQL获取当前时间(以秒/毫秒为单位)?
- 6. 如何查找两次之间的时间间隔(以毫秒为单位)?
- 7. 如何使用XAudio2寻找以毫秒为单位的位置
- 8. 使用boost :: date_time库格式化时间以毫秒为单位
- 9. 使用本地存储需要时间以毫秒为单位
- 10. 带时间戳的搜索时间(以毫秒为单位)influxdb
- 11. 典型时间格式的时间(以毫秒为单位)
- 12. NetStream.seek以毫秒为单位
- 13. TimeSpan.ParseExact以毫秒为单位
- 14. 转换“时间”,“单位”,以毫秒为单位
- 15. 以毫秒为单位的TImespan,以分钟和秒为单位
- 16. 时间选择器以毫秒为单位以毫秒为单位计算出错误的值
- 17. TimePicker以毫秒为单位倒计时
- 18. java将时间戳以秒为单位转换为以毫秒为单位的时间戳
- 19. R 2列之间的时间差(以毫秒为单位)
- 20. 来自BPM(Midi tempo)的时间间隔(以毫秒为单位)
- 21. 以毫秒为单位检测秒数
- 22. 用C#转换任何时间格式(以毫秒为单位)
- 23. 如何从两个日期时间戳字段使用ruby查找时间差(以毫秒为单位)
- 24. 如何获得以毫秒为单位的时间?
- 25. 以毫秒为单位的HTML5时间元素
- 26. 以毫秒为单位解析Perl的时间戳
- 27. 以毫秒为单位获取ViewPager视图的时间
- 28. Android中的日期和时间以毫秒为单位
- 29. 以毫秒为单位的减法时间
- 30. Laravel获取created_at以毫秒为单位的时间戳