VERSION 5.00
Begin VB.Form frmMain
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdEnd
Caption = "结束"
Height = 375
Left = 2880
TabIndex = 3
Top = 2280
Width = 855
End
Begin VB.CommandButton cmdRestore
Caption = "恢复"
Height = 495
Left = 3240
TabIndex = 2
Top = 960
Width = 975
End
Begin VB.CommandButton cmdPause
Caption = "暂停"
Height = 375
Left = 1200
TabIndex = 1
Top = 1440
Width = 1335
End
Begin VB.CommandButton cmdStart
Caption = "执行"
Height = 495
Left = 1320
TabIndex = 0
Top = 360
Width = 1335
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private isPause As Boolean
Private isEnd As Boolean
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub PauseFun()
Do While isPause
If isEnd Then
Unload Me: End
Exit Sub
End If
DoEvents
Sleep 10
Loop
End Sub
Private Sub cmdEnd_Click()
If Not isPause Then
Unload Me: End
Else
isEnd = True
End If
End Sub
Private Sub cmdPause_Click()
isPause = True
End Sub
Private Sub cmdRestore_Click()
isPause = False
End Sub
Private Sub cmdStart_Click()
Dim i As Long
For i = 0 To 1000000000
DoEvents
If isPause Then
Call PauseFun
End If
Open App.Path & "/text.txt" For Append As #1
Print #1, i
Close #1
Next
End Sub