vb程序中如何获取程序运行的时间(本身程序)
如题二楼,你的代码可行,非常感谢(同样谢谢一楼),不过只能获得秒数,能不能把他像显示时间一样从00:00:00开始跳动,(当程序启动时)...
如题
二楼,你的代码可行,非常感谢(同样谢谢一楼),不过只能获得秒数,能不能把他像显示时间一样从00:00:00开始跳动,(当程序启动时) 展开
二楼,你的代码可行,非常感谢(同样谢谢一楼),不过只能获得秒数,能不能把他像显示时间一样从00:00:00开始跳动,(当程序启动时) 展开
2个回答
展开全部
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim sTime&, t%, vHou%, vMin%, vSec%
Private Sub Form_Load()
sTime = GetTickCount
Timer1.Interval = 500
Call rTime
End Sub
Private Sub Timer1_Timer()
Call rTime
End Sub
Sub rTime()
t = (GetTickCount - sTime) / 1000
vHou = Int(t / 3600)
vMin = (t - vHou) \ 60
vSec = Int(t - vHou - vMin)
Me.Caption = "程序已运行 " & IIf(Len(CStr(vHou)) = 1, "0" & vHou, vHou) & ":" & IIf(Len(CStr(vMin)) = 1, "0" & vMin, vMin) & ":" & IIf(Len(CStr(vSec)), "0" & vSec, vSec)
End Sub
窗体上放一Timer控件
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim sTime&, t%, vHou%, vMin%, vSec%
Private Sub Form_Load()
sTime = GetTickCount
Timer1.Interval = 500
Call rTime
End Sub
Private Sub Timer1_Timer()
Call rTime
End Sub
Sub rTime()
t = (GetTickCount - sTime) / 1000
vHou = Int(t / 3600)
vMin = (t - vHou) \ 60
vSec = Int(t - vHou - vMin)
Me.Caption = "程序已运行 " & IIf(Len(CStr(vHou)) = 1, "0" & vHou, vHou) & ":" & IIf(Len(CStr(vMin)) = 1, "0" & vMin, vMin) & ":" & IIf(Len(CStr(vSec)), "0" & vSec, vSec)
End Sub
窗体上放一Timer控件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim start As Long
Private Sub Form_Load()
start = Timer
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim sums As Integer
sums = Int(Timer - start)
h = Int(sums / 3600)
m = Int((sums - 3600 * h) / 60)
s = sums - 3600 * h - 60 * m
Me.Caption = "程序已运行 " & Format(h, "00") & ":" & Format(m, "00") & ":" & Format(s, "00")
End Sub
Private Sub Form_Load()
start = Timer
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim sums As Integer
sums = Int(Timer - start)
h = Int(sums / 3600)
m = Int((sums - 3600 * h) / 60)
s = sums - 3600 * h - 60 * m
Me.Caption = "程序已运行 " & Format(h, "00") & ":" & Format(m, "00") & ":" & Format(s, "00")
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询