延时求教高手:我用函数sleep做了一个延时效果,但是在sleep起作用时,其他好像也被延时,求教解决方法如:picVolume为picturebox控件Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()
Sleep (6000)
End SubPrivate Sub picVolume_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If X < 0 Then X = 0
If X > picVolume.Width Then X = picVolume.Width
FindVolume CLng(X)
End If
End Sub
Private Sub picVolume_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
picVolume_MouseDown Button, Shift, X, Y
End Sub
Private Sub FindVolume(lVol As Long)
lVolume = lVol
picVolume.Cls
picVolume.Line (0, 0)-(lVol, picVolume.Height), &HC0E0FF, BF
End Sub
Sleep (6000)
End SubPrivate Sub picVolume_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If X < 0 Then X = 0
If X > picVolume.Width Then X = picVolume.Width
FindVolume CLng(X)
End If
End Sub
Private Sub picVolume_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
picVolume_MouseDown Button, Shift, X, Y
End Sub
Private Sub FindVolume(lVol As Long)
lVolume = lVol
picVolume.Cls
picVolume.Line (0, 0)-(lVol, picVolume.Height), &HC0E0FF, BF
End Sub
Dim a As Long
a = Timer
Do Until Timer > a + 6: DoEvents: Loop
End Sub
Option ExplicitPrivate Declare Function SetTimer Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As LongPrivate lnghWnd As Long
Sub Test() KillTimer lnghWnd, 1
'添加COMMAND1要执行的代码
End SubSub Delay(ByVal hWnd As Long, ByVal lngT As Long)
lnghWnd = hWnd
SetTimer lnghWnd, 1, lngT, AddressOf Test
End Sub下面是Command1的Click事件,延时3秒
Private Sub Command1_Click()
Call Delay(Me.hWnd, 3000)
End Sub