注意晚上0:00,要写一句dim t_time as longt_time=timerif t_time=0 then t_time=1
if 程序运行 then timer1.enabled=trueprivate sub timer1_timer() If se > 59 Then se = 0 m = m + 1 Else se = se + 1 End If If m > 59 Then m = 0 h = h + 1 End If If h > 24 Then h = 0 d = d + 1 End If lblljsj.Caption = Trim(Str(d)) + "天" + Trim(Str(h)) + "小时" + Trim(Str(m)) + "分" end sub这是我以前写的程序中的,不知道对你有没有用.
用API比较准确. timeGetTime或GetTickCount都可以.
在窗口中加入一个TIMER1其Interval设为1000,再加入一个TEXTBOXOption Explicit Dim StartTime As DatePrivate Sub Form_Load() StartTime = Now End SubPrivate Sub Timer1_Timer() Text1.Text = FormatDateTime(DateAdd("s", DateDiff("s", StartTime, Now), "00:00:00"), vbLongTime) End Sub
先定义一个timer tmrAction在form上,index=0然后就可以运行时用load tmrAction(i) 创建一个新的timer (i是整数)
运行完取t2=time
运行时间为两者之差
If se > 59 Then
se = 0
m = m + 1
Else
se = se + 1
End If
If m > 59 Then
m = 0
h = h + 1
End If
If h > 24 Then
h = 0
d = d + 1
End If
lblljsj.Caption = Trim(Str(d)) + "天" + Trim(Str(h)) + "小时" + Trim(Str(m)) + "分"
end sub这是我以前写的程序中的,不知道对你有没有用.
timeGetTime或GetTickCount都可以.
Dim StartTime As DatePrivate Sub Form_Load()
StartTime = Now
End SubPrivate Sub Timer1_Timer()
Text1.Text = FormatDateTime(DateAdd("s", DateDiff("s", StartTime, Now), "00:00:00"), vbLongTime)
End Sub