想调用一个函数等待30秒
再执行下面的语句
再执行下面的语句
解决方案 »
- 数据库的地址能不能用一个外部文件来调用?
- 我的程序为什么在Windows2003里不能用?
- 我这样定义为什么会出现错误?
- 请教高手!!
- 谁给我个VB的收费软件参考下啊!!要原码的
- 怎么获得SQL SERVER 的版本信息 , 以及确定是否安装了企业管理器(Enterprise Manager)
- 最简单的数据库问题
- 怎樣用printer命令把picturebox內的圖片打印出來
- 求Exchange server 2000 的序列号,在线。。。。。。。。。。。。。
- vb中如何用dao实现模糊查询功能?
- 【请问高手,怎么可以实现跨网段进行实时更新?】高分!!!!!
- 中秋佳节快乐--------------散分
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
单位是毫秒'***********************************
Public Sub Wait(delay As Single)
'单位是秒,例如3.5s starttime! = Timer
Do Until Timer >= starttime! + delay
LoopEnd Sub
用一个循环也可以。
for i = 0 to 10000
next
Public Sub BKWait(HowManySecs)
Dim EndWait
EndWait = DateAdd("s", HowManySecs, Now)
While Now < EndWait
'空语句
WendEnd Sub
例如:
......
BKWait(30)
......
i=1
do while i<1000
DoEvents
loopDoEvents这个语句在好多别人程序中见过,好像是让程序等待一会儿,具体是待多长时间,我也不清楚。
Private Declare Function timeGetTime Lib "winmm.dll" () As LongDim SaveTime As Double
Dim OverTime As Long
OverTime = 2000 '延迟2000毫秒
SaveTime = timeGetTime '记下开始时的时间
Do Until timeGetTime - SaveTime >= OverTime '延迟
DoEvents
Loop
ltime =Timer()
While Timer() - ltime <= 20 * 0.05 '延时20×0.05s
DoEvents
Wend
做一个延迟的小程序
Gettickcount是一个asp函数,表示是自电脑开机以来所经历的时间
Declare Function GetTickCount Lib "kernel32" () As Long ‘声明函数
public function time_delay (nowtime as long ,timelong as long )
do
doevents
loop until abs(gettickcount-nowtime)>timelong
end function
建好模块 然后引用该函数,如下所示:
Dim time_tep as long
Time_tep=50
Call time_delay (gettickcount,time_tep) ‘延迟50毫秒
Dim Start As Long
Dim I As Integer
For I = 1 To fire_floor_count
Start = Timer
SoundFileName$ = App.Path & "\sound\" + CStr(fire_floor_num(I)) + ".wav"
sndPlaySound SoundFileName$, Flags&
Do While Timer < Start + 3 ' 3 秒的延时
DoEvents
Loop
Next I
End Sub
这是播放wav时的时间延迟(3s)DoEvents是转让控制权,以便让操作系统处理其它的事件。不然的话你的整个程序都停在哪儿了!
'ムモハアコッハ
On Error Resume Next
Dim endofdelay
endofdelay = DateAdd("n", mins, Now)
endofdelay = DateAdd("s", secs, endofdelay)
delay = 0
Do While (Now < endofdelay)
DoEvents
If Not IsMissing(stopflag) Then
If stopflag Then
delay = 1
stopflag = False
Exit Do
End If
End If
LoopEnd Function
Private Declare Function timeGetTime Lib "winmm.dll" () As LongSub Delay(Byval DelayTime As Long) '单位是毫秒
DelayTime =DelayTime + Timegettime
Do While Timegettime < DelayTime
DoEvents
Loop
End Sub调用的时候这样写:
...
Delay 1000 '延时一秒
...用这个过程比较好,不会造成程序“假死”的现象。
Dim BeginTime As Single
BeginTime = Timer
While Timer < BeginTime + DelayTime
DoEvents
Wend
End Subdelay 1.5