使用timer控件不好,因为间隔设置太长不能及时停止,太短影响程序运行。最好的方法是设置一个变量来指示暂停标志。如下程序,在窗体中放置两个command按钮,一个label1标签,单击command1,标签值从1~1000000开始变化,随时按command2计划停止变化,再按继续。
dim
pause
as
boolean,
i
as
long
private
sub
command1_click()
for
i
=
1
to
1000000
doevents
do
while
pause
=
true
doevents
loop
label1
=
i
next
end
sub
private
sub
command2_click()
pause
=
not
pause
end
sub
private
sub
form_load()
pause
=
false
end
sub