
在vb中怎样显示毫秒?
4个回答
展开全部
使用GetTickCount
Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
起点和终点各调用一次,取时间差,以毫秒为单位
t=GetTickCount
'……
'……
'你的代码
'……
'……
t=GetTickCount-t
最后得出来的t就是毫秒为单位的
Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
起点和终点各调用一次,取时间差,以毫秒为单位
t=GetTickCount
'……
'……
'你的代码
'……
'……
t=GetTickCount-t
最后得出来的t就是毫秒为单位的
展开全部
Function GetMiniTime() As String
Dim Tss As Single, HM As Integer, SS As Integer, MM As Integer, HH As Integer
Tss = Timer() * 1000
HM = Tss Mod 1000 '得到毫秒
Tss = Tss \ 1000 '总秒数
HH = Tss \ 3600 '得到小时
Tss = Tss Mod 3600 '总分钟数
MM = Tss \ 60 '得到分钟
SS = Tss Mod 60 '得到秒
GetMiniTime = Format(HH, "00") & ":" & Format(MM, "00") & ":" & Format(SS, "00") & "." & Format(HM, "000")
End Function
测试:
Private Sub Form_Load()
Me.Caption = GetMiniTime
End Sub
Dim Tss As Single, HM As Integer, SS As Integer, MM As Integer, HH As Integer
Tss = Timer() * 1000
HM = Tss Mod 1000 '得到毫秒
Tss = Tss \ 1000 '总秒数
HH = Tss \ 3600 '得到小时
Tss = Tss Mod 3600 '总分钟数
MM = Tss \ 60 '得到分钟
SS = Tss Mod 60 '得到秒
GetMiniTime = Format(HH, "00") & ":" & Format(MM, "00") & ":" & Format(SS, "00") & "." & Format(HM, "000")
End Function
测试:
Private Sub Form_Load()
Me.Caption = GetMiniTime
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建一个Timer1.
代码如下。
============
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Dim t As SYSTEMTIME
GetLocalTime t
Cls
Print DateSerial(t.wYear, t.wMonth, t.wDay) & " " & TimeSerial(t.wHour, t.wMinute, t.wSecond) & "." & t.wMilliseconds
End Sub
代码如下。
============
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Dim t As SYSTEMTIME
GetLocalTime t
Cls
Print DateSerial(t.wYear, t.wMonth, t.wDay) & " " & TimeSerial(t.wHour, t.wMinute, t.wSecond) & "." & t.wMilliseconds
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询