我是这么写的代码: Dim starttimePrivate Sub Command1_Click() ss = (Time - starttime) * 100000 Label2.Caption = Time Debug.Print ss End SubPrivate Sub Form_Load() starttime = Time() Label1.Caption = Time() End Sub 但是我发现有问题:如果多次单击command1,而且相隔的时间越长,结果就出现很大的偏差,你试试看!
Private t1 As Single Private t2 As Single......t1 = Timer .... .... '你的过程 .... .... t2 = Timer运行时间既为 t2 - t1 单位是秒 不过这个方法不能用在跨天的程序中,如果跨天,需要判断跨了几天,做相应调整 因为 Timer 函数每天 00:00 清零
一般过程不会过长吧: Private Sub Form_Load() Dim x(10000, 3) As String time1 = Time For i = 0 To 9999 For j = 0 To 2 x(i, j) = i * j Next Next MsgBox DateDiff("s", time1, Time) & "ms" End Sub
Dim starttimePrivate Sub Command1_Click()
ss = (Time - starttime) * 100000
Label2.Caption = Time
Debug.Print ss
End SubPrivate Sub Form_Load()
starttime = Time()
Label1.Caption = Time()
End Sub
但是我发现有问题:如果多次单击command1,而且相隔的时间越长,结果就出现很大的偏差,你试试看!
Private t2 As Single......t1 = Timer
....
....
'你的过程
....
....
t2 = Timer运行时间既为 t2 - t1 单位是秒
不过这个方法不能用在跨天的程序中,如果跨天,需要判断跨了几天,做相应调整
因为 Timer 函数每天 00:00 清零
Private Sub Form_Load()
Dim x(10000, 3) As String
time1 = Time
For i = 0 To 9999
For j = 0 To 2
x(i, j) = i * j
Next
Next
MsgBox DateDiff("s", time1, Time) & "ms"
End Sub