' Win32API Examle - Sleep
'
' Jon Vote 02/2002
'
' 1) Create a new project. Form1 will be created by default.
' 2) Add a Command Button to the form.
' 3) Paste the following code into the declarations section of Form1:
' --- Begin code for Form1 ---
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
Me.Caption = "Win32API - Sleep Example"
Command1.Caption = "&Sleep"
End Sub
Private Sub Command1_Click()
Dim lngMiliSeconds As Long
lngMiliSeconds = Val(InputBox$("Sleep for how long (Miliseconds)?", "Sleep Example", 2000))
If MsgBox("Sleep for " & lngMiliSeconds & " miliseconds?", vbOKCancel, "Sleep") = vbOK Then
Cls
Print "Now is: " & Now
Print "Sleeping until: " & DateAdd("s", lngMiliSeconds / 1000, Now)
DoEvents
Sleep lngMiliSeconds
MsgBox "Done"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
' --- End code for Form1 ---