我一般都是这样做的,做一个 function doeventsrun(tjid,count) 计时: for ii=1 to count call tjsub(tjid) 得到计时结果 得到速度次/秒 end functiontjsub(tjid) select case tjid ***要运行的代码 *** end select end sub操作: doeventsrun 3,1000次 然后把3的代码讣告到tjsub,当然我也试过很多种方法,不过没系统整理过,反正怎么方便怎么做
dim t1 as long t1=gettickcount do while (gettickcount-t1)/1000<30 call a'a在30秒内都运行 nextprivate sub a() end sub
给你两个延时程序,你参考,给分吧 Function TmDelay(Tm As Integer) Dim tmstart As Long Dim Tm1 As Long tmstart = timeGetTime + Tm 'Do While timeGetTime < tmstart Do While Tm1 < tmstart Tm1 = timeGetTime DoEvents Loop End Function ‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘ Sub delay(interval As Single) '延迟子程序 Dim start start = Timer Do While Timer < start + interval Loop End Sub
晕,看错了 既然知道了这段代码运行时长 那么放2个时钟发生器 timer1 interval =时长 timer2 interval =30秒 定义一个公共boolean型变量bContinue dim bcontinue as boolean bcontinue=false private sub timer1_timer'发生一次刚好运行完 if bcontinue=true then timer1.enable=false exit sub end sub private sub timer2'30秒 bcontine=true end sub
Print Now
' ...............
'代码
'........
Print Now
End Function
function doeventsrun(tjid,count)
计时:
for ii=1 to count
call tjsub(tjid)
得到计时结果
得到速度次/秒
end functiontjsub(tjid)
select case tjid
***要运行的代码
***
end select
end sub操作:
doeventsrun 3,1000次
然后把3的代码讣告到tjsub,当然我也试过很多种方法,不过没系统整理过,反正怎么方便怎么做
t1=gettickcount
do while (gettickcount-t1)/1000<30
call a'a在30秒内都运行
nextprivate sub a()
end sub
Function TmDelay(Tm As Integer)
Dim tmstart As Long
Dim Tm1 As Long
tmstart = timeGetTime + Tm
'Do While timeGetTime < tmstart
Do While Tm1 < tmstart
Tm1 = timeGetTime
DoEvents
Loop
End Function
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘
Sub delay(interval As Single) '延迟子程序
Dim start
start = Timer
Do While Timer < start + interval
Loop
End Sub
既然知道了这段代码运行时长
那么放2个时钟发生器
timer1 interval =时长
timer2 interval =30秒
定义一个公共boolean型变量bContinue
dim bcontinue as boolean
bcontinue=false
private sub timer1_timer'发生一次刚好运行完
if bcontinue=true then
timer1.enable=false
exit sub
end sub
private sub timer2'30秒
bcontine=true
end sub