dim starttm&,ISStop as boolean '放到最上面通用区
Sub WaitMe(Delaytm&)
ISStop = False
Starttm = Timer
Do
DoEvents
If ISStop Then Exit Do
Loop Until Timer - Starttm > = Delaytm '假设DElayym等于5, 5秒后不管有没有被激发都退出Do...Loop
End Sub
If Me.Stop.Caption = "暂停" Then
Me.Stop.Caption = "继续"
ISStop = False
Call WaitMe
Else
Me.Stop.Caption = "暂停"
'''''''''''''''''''''''''Thread_Suspend = ResumeThread(hThread) '不要
ISStop = True
End If
End Sub
Sub WaitMe()
Do Until ISStop
DoEvents
sleep(1)
Loop
ISStop = False
End Sub
Dim i&, Starttm&, ForceStop As Boolean
Private Sub Form_Load()
Command1.Caption = "开 始"
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
Select Case Command1.Caption
Case Is = "暂 停"
Timer1.Enabled = False
Command1.Caption = "继 续"
Call MySleep(10)
Case Is = "继 续"
Timer1.Enabled = True
Command1.Caption = "暂 停"
ForceStop = True
Case Else
Timer1.Enabled = True
Command1.Caption = "暂 停"
End Select
End Sub
Private Sub Timer1_Timer()
Me.Caption = CStr(i)
i = IIf(i >= 1000, 0, i + 1)
End Sub
Sub MySleep(Delaytm&)
Command1.Caption = "继 续"
ForceStop = False
Starttm = Timer
Do
DoEvents
If ForceStop Then Exit Do
Loop Until Timer - Starttm >= Delaytm
Command1.Caption = "开 始"
Command1_Click
End Sub
Dim i&, Starttm&, ForceStop As Boolean
Private Sub Form_Load()
Command1.Caption = "开 始"
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
Select Case Command1.Caption
Case Is = "暂 停"
Timer1.Enabled = False
Command1.Caption = "继 续"
Call MySleep(10)
Case Is = "继 续"
Timer1.Enabled = True
Command1.Caption = "暂 停"
ForceStop = True
Case Else
Timer1.Enabled = True
Command1.Caption = "暂 停"
End Select
End Sub
Private Sub Timer1_Timer()
Me.Caption = CStr(i)
i = IIf(i >= 1000, 0, i + 1)
End Sub
Sub MySleep(Delaytm&)
Command1.Caption = "继 续"
ForceStop = False
Starttm = Timer
Do
DoEvents
If ForceStop Then Exit Do
Loop Until Timer - Starttm >= Delaytm
Command1.Caption = "开 始"
Command1_Click
End Sub
Dim i&, Starttm&, ForceStop As Boolean
Private Sub Form_Load()
Command1.Caption = "开 始"
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
Select Case Command1.Caption
Case Is = "暂 停"
Timer1.Enabled = False
Command1.Caption = "继 续"
Call MySleep(10)
Case Is = "继 续"
Timer1.Enabled = True
Command1.Caption = "暂 停"
ForceStop = True
Case Else
Timer1.Enabled = True
Command1.Caption = "暂 停"
End Select
End Sub
Private Sub Timer1_Timer()
Me.Caption = CStr(i)
i = IIf(i >= 1000, 0, i + 1)
End Sub
Sub MySleep(Delaytm&)
Command1.Caption = "继 续"
ForceStop = False
Starttm = Timer
Do
DoEvents
If ForceStop Then Exit Do
Loop Until Timer - Starttm >= Delaytm
Command1.Caption = "开 始"
Command1_Click
End Sub