Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)sleep 180000

解决方案 »

  1.   

    '1.程式名称:三种延迟程式执行的方法
    '2.开发日期:04/10/1998
    '3.开发环境:Visual Basic 5.0 中文专业版 + SP3
    '4.作者姓名:宋世杰 (小翰,Jaric)
    '5.作者信箱:[email protected]
    '6.作者网址:http://fly.to/jaric 或 http://tacocity.com.tw/jaric
    '7.网址名称:Visual Basic 实战网
    '8.注意事项:您可以任意散布本程式,但是请勿将以上说明删除,谢谢!
    '                     如果本程式经过您的修改,可以在下方加入您的个人资讯。Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Public Sub Delay1(second As Single)
         Dim BeforeTime As Single
         BeforeTime = Timer
         Do
         Loop Until Timer > BeforeTime + second
    End SubPublic Sub Delay2(second As Single)
         Dim BeforeTime As Long
         BeforeTime = GetTickCount
         Do
         Loop Until GetTickCount > BeforeTime + second * 1000
    End SubPublic Sub Delay3(second As Single)
         Sleep second * 1000
    End SubPrivate Sub Command1_Click()
         Call Delay1(5)
    End SubPrivate Sub Command2_Click()
         Call Delay2(5)
    End SubPrivate Sub Command3_CLick()
         Call Delay3(5)
    End Sub
      

  2.   

    'This project needs a button
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Command1_Click()
        Me.Caption = "Your system will sleep 5 sec."
        'Sleep for 5000 milliseconds
        Sleep 5000
        Me.Caption = ""
    End Sub
    Private Sub Form_Load()
        Me.Caption = ""
        Command1.Caption = "Sleep ..."
    End Sub