# Re: 如何将已执行的程序(procedure)中止

Posted by 柏先生 on April 08, 1999 at 15:43:04:

In Reply to: 如何将已执行的程序(procedure)中止 posted by 阿甘 on April 08, 1999 at 14:55:35:

: example :
: sub form_load()
: showGrid
: end sub
dim bKey as boolean

: sub showGrid()
: vsql="select * from data"
: set rs=db.openrecordset(vsql)
: while rs.eof
: irow=irow+1
: msflexgrid.textmatrix(irow,0)=rs(0)
: .......
****** 增加几句代码
if bKey then
bKey=False
exit sub
end if
Doevents
****** 增加结束
: rs.movenext
: wend
: set rs=nothing
: end sub
: 突然发现data太多想停止执行,不知要如何做才好?
: Give me help?,thanks!

sub GetKey_KeyUp(byval Keycode as Integer)
if keycode=vbKeyEscape then
bKey=True
end if
End Sub

这样一按ESC键，程序终止。

Follow Ups: