VB延时有几种方法?哪个更好?
VB延时有几种方法?哪个更好?最好给出相关代码实例. VB
[解决办法]
没有最好吧,适合就好,比如sleep,比如doevents,再比如要用到线程的那些。
[解决办法]
http://download.csdn.net/detail/sysdzw/752060
楼主试试上面这个,目前我一直使用的,不卡。
[解决办法]
本帖最后由 bcrun 于 2013-06-11 09:35:38 编辑
public sub delay(mSecond as long,optional bDoevents as boolean=false)
dim t0 as long
t0=gettickcount
while gettickcount-t0<mSecond
if bdoevents then doevents
sleep 10
wend
end sub
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds) As Long'声明
Sleep(3000) '使用 停止3秒
Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long '声明
'要延迟的话这里给个简单范例
Private Sub Delay (milliseconds)
Dim time_start as long
time_start = GetTickCount()
Do While GetTickCount()-time_start<milliseconds
DoEvents
Loop
End Sub
Private Declare Function GetTickCount Lib "kernel32" () As Long
'lngTime:延迟的ms数
private sub subDelay(byval lngTime as long)
dim lngP as long
if lngTime<=0 then exit sub
lngP=Gettickcount
do
DoEvents
loop until Gettickcount-lngP>=lngTime
end sub