# Re: 纪兄,你猜对我的意思,但有个问题.

Posted by 纪文和 on August 12, 1999 at 21:19:16:

In Reply to: 纪兄,你猜对我的意思,但有个问题. posted by kkcheung on August 12, 1999 at 15:05:09:

Doevents 必须加在 For 回圈中, 否则没用.
程式虽然在运作, 但是 Doevent 会让它停一会的. 这时它就会处理另一个按钮的动作 !!

完整程式如下:
’Form　的宣告区
Dim wflag As String

Private Sub Command1_Click()
Dim i As Long
For i = 1 To 100000
i = i + 1
DoEvents
If wflag = "ok" Then
wflag = "" '下次可再按 command2 来停止
MsgBox i
Exit For
End If
Next
End Sub

Private Sub Command１_Click()
wflag = "ok"
End Sub

VB入门网

Follow Ups: