不知道是不是这个意思:option explicit Dim isStop As Boolean Private Sub Command1_Click() For j = 0 To 1000000 DoEvents If isStop = True Then Exit For Text1.Text = j Next j End SubPrivate Sub Command2_Click() isStop = True End SubPrivate Sub Form_Load() isStop = False End Sub
可以用进程, 也可以用时钟。 不过要把上楼仁兄的最后一个事件变为 priveter sub timer_in......() isStop = False end sub 具体什么事件,我忘了, 但时钟控件就一个事件。
Dim isStop As Boolean
Private Sub Command1_Click()
For j = 0 To 1000000
DoEvents
If isStop = True Then Exit For
Text1.Text = j
Next j
End SubPrivate Sub Command2_Click()
isStop = True
End SubPrivate Sub Form_Load()
isStop = False
End Sub
也可以用时钟。
不过要把上楼仁兄的最后一个事件变为
priveter sub timer_in......()
isStop = False
end sub
具体什么事件,我忘了,
但时钟控件就一个事件。
如果没有写,那么系统在loop期间是不会处理其他事件的除非loop中止
tygh2000(峰)的方法可以达到你要的效果,不过一旦停了就得从头来过。
对tygh2000(峰)的方法稍作改动就可以从断点处继续走下去。
就是另外定义三个变量:
1.LoopCount (用于循环计数)
2.LoopEnd (循环的最大值或最小值)
3.LoopStep (循环的步长)
在循环暂停的时候用LoopCount记下当前停下时i的数值,在下次启动时只要i=LoopCount就行了。
根据需要LoopStep可以用来改变循环方向(一旦改变LoopEnd也要改变)
这样就可以动态的改变循环执行的状态