8 个解决方案
#1
sleep()
是你先声明这个api函数
是你先声明这个api函数
#2
Dim StopTheTimer As Boolean
Public Function Delay(Mins%, Secs%, Optional ByRef StopFlag) As Long
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
Loop
End Function
Private Sub Command1_Click() '开始延时
Dim lRetval&
'lRetval = Delay(分,秒, StopTheTimer)
lRetval = Delay(0, 5, StopTheTimer)
If lRetval = 0 Then
MsgBox "时间到!"
Else
MsgBox "取消延时!"
End If
End Sub
Private Sub Command2_Click() '取消延时
StopTheTimer = True
End Sub
Public Function Delay(Mins%, Secs%, Optional ByRef StopFlag) As Long
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
Loop
End Function
Private Sub Command1_Click() '开始延时
Dim lRetval&
'lRetval = Delay(分,秒, StopTheTimer)
lRetval = Delay(0, 5, StopTheTimer)
If lRetval = 0 Then
MsgBox "时间到!"
Else
MsgBox "取消延时!"
End If
End Sub
Private Sub Command2_Click() '取消延时
StopTheTimer = True
End Sub
#3
Sleep,用Timer也可做到延时
#4
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Call Sleep(2000) ;延时2秒
Call Sleep(2000) ;延时2秒
#5
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#6
DateDiff
其实完全一样,都是同步的
其实完全一样,都是同步的
#7
用Sleep会导致应用程序失去响应,最好不要延迟太长
#8
贴子回复次数大于跟给分次数
是什么意思
是什么意思
#1
sleep()
是你先声明这个api函数
是你先声明这个api函数
#2
Dim StopTheTimer As Boolean
Public Function Delay(Mins%, Secs%, Optional ByRef StopFlag) As Long
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
Loop
End Function
Private Sub Command1_Click() '开始延时
Dim lRetval&
'lRetval = Delay(分,秒, StopTheTimer)
lRetval = Delay(0, 5, StopTheTimer)
If lRetval = 0 Then
MsgBox "时间到!"
Else
MsgBox "取消延时!"
End If
End Sub
Private Sub Command2_Click() '取消延时
StopTheTimer = True
End Sub
Public Function Delay(Mins%, Secs%, Optional ByRef StopFlag) As Long
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
Loop
End Function
Private Sub Command1_Click() '开始延时
Dim lRetval&
'lRetval = Delay(分,秒, StopTheTimer)
lRetval = Delay(0, 5, StopTheTimer)
If lRetval = 0 Then
MsgBox "时间到!"
Else
MsgBox "取消延时!"
End If
End Sub
Private Sub Command2_Click() '取消延时
StopTheTimer = True
End Sub
#3
Sleep,用Timer也可做到延时
#4
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Call Sleep(2000) ;延时2秒
Call Sleep(2000) ;延时2秒
#5
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#6
DateDiff
其实完全一样,都是同步的
其实完全一样,都是同步的
#7
用Sleep会导致应用程序失去响应,最好不要延迟太长
#8
贴子回复次数大于跟给分次数
是什么意思
是什么意思