iFIX时间获取,精确到毫秒

‘获取系统的精确时间,精确到毫秒

Private Function Msecond() As String

‘Get system time

Dim t As Double

Dim h, m, s As Integer

Dim ss As String

 

t = Timer

h = Int(t / 3600)

m = Int((t – 3600 * h) / 60)

s = Int(t – h * 3600 – m * 60)

 

If InStr(1, CStr(t), “.”) <> 0 Then

ss = Mid(CStr(t), InStr(1, CStr(t), “.”), 4)

Else

ss = “.”

End If

 

Select Case Len(ss)

Case 0, 1

ss = “.000”

Case 2

ss = ss & “00”

Case 3

ss = ss & “0”

End Select

 

Msecond = Format(Now, “yyyy/mm/dd hh:mm:ss”) & ss

End Function

徐大军

发表评论

电子邮件地址不会被公开。 必填项已用*标注