使用 VBScript 以毫秒为单位查找时间 [英] Find time with millisecond using VBScript

查看:31
本文介绍了使用 VBScript 以毫秒为单位查找时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以毫秒为单位获取时间当前使用 Timer() 方法,但它只允许访问秒任何的想法?

I want to get time with millisecond Currently using Timer() method but it just give access upto second Any idea?

请确保我不想将秒转换为毫秒想要获得毫秒

Please make sure i don't want to convert second into millisecond want to get with millisecond

推荐答案

事实上 Timer 函数给你以毫秒为单位的秒数.返回值的整数部分是从午夜开始的秒数,小数部分可以转换为毫秒 - 只需乘以 1000.

In fact Timer function gives you seconds with milliseconds. Integer part of returned value is the number of seconds since midnight and the fraction part can be converted into milliseconds - just multiply it by 1000.

t = Timer

' Int() behaves exactly like Floor() function, i.e. it returns the biggest integer lower than function's argument
temp = Int(t)

Milliseconds = 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, Milliseconds

' 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(Milliseconds), "0") & Milliseconds

WScript.Echo strTime

这篇关于使用 VBScript 以毫秒为单位查找时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆