如何让VB程序在执行完某个语句的时候就等待一段时间(可以自己设定时间),再继续执行?(不用Timer控件可以吗?)
因为我的程序中太频繁调用SQL中的存储过程,我担心这样会影响SERVER性能,所以我希望每执行
一个存储过程就等待几秒钟再继续执行!!!

解决方案 »

  1.   

    '*API函数声明:
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    '调用:
    '注释:延时1秒
    Call Sleep(1000) 
      

  2.   

    盗版楼上的,抢分:
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)调用方法:
    ...
    Sleep(1000) '等待1000毫秒。
    ...嘿嘿,加点说明,盗亦有道。
      

  3.   

    Sleep函数。只是使计算机休眠,休眠其间计算机不做任何事情。
      

  4.   

    PauseTime = 1 ' 设置暂停时间。
            Start = Timer   ' 设置开始暂停的时刻。
            Do While Timer < Start + PauseTime
               DoEvents   ' 将控制让给其他程序。
            Loop
      

  5.   

    dim T1 as date,T2 as date,N as long
    t1=now:t2=now
    do until abs(datediff("s",t1,t2))>=n
     t2=now:doevents:sleep 1
    loop
    这样不占资源,不影响程序的其他部分执行。
      

  6.   

    '*API函数声明:
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    '调用:
    '注释:延时1秒
    Call Sleep(1000)
      

  7.   

    Function Delay(ByVal n As Single)
        Dim tm1, tm2 As Single
        tm1 = Timer
        Do
           tm2 = Timer
           If tm2 < tm1 Then tm2 = tm2 + 86400
           If tm2 - tm1 > n Then Exit Do
           DoEvents
        Loop
        
    End Function