在你的程序你面设置一个参数ZANTING,如果按钮1点击,则ZANTING=1,程序进入死循环,如果按钮2点击,则ZANTING=0,程序跳出死循环 代码如下:
在你的程序里面写如下代码:
waitdone2:
If ZANTING = 1 Then
System.Threading.Thread.Sleep(100)
GoTo waitdone2
End If
If ZANTING = 0 Then
GoTo NEXTdone2
End If
NEXTdone2:
在按钮里面写如下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ZANTING = 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ZANTING = 0
End Sub
设置一个标记量,按钮按一下=true,再按=false;程序里需要暂停的地方检测这个量,等他=true再接着运行。
Dim k
Private Sub Command1_Click()
If k = 1 Then
暂停
k = 0
Else
执行
k = 1
End If
End Sub