关闭

VB 给你的程序提供暂停功能

标签: vb360
6995人阅读 评论(2) 收藏 举报
分类:

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
 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:326353次
    • 积分:4455
    • 等级:
    • 排名:第6975名
    • 原创:81篇
    • 转载:0篇
    • 译文:2篇
    • 评论:431条
    文章分类
    最新评论
    chenhui530新浪博客