我有这段代码的问题:如何暂停一个循环内的动画无延迟
Do While StopProgram = False
Do Until Count = v
Application.DoEvents()
Do While StopProgram = False
If DirectionNegative = False Then
Me.Refresh()
Count += 1
Angle += 1
RadianAngle = Angle * PlaceHolder
If Angle >= 51 Then
Angle = 49
DirectionNegative = True
End If
ElseIf DirectionNegative = True Then
Me.Refresh()
Count += 1
Angle -= 1
RadianAngle = Angle * PlaceHolder
If Angle <= -51 Then
Angle = -49
DirectionNegative = False
End If
End If
Loop
Loop
Count = 0
Loop
的问题是,当我按我的表单上的按钮,停止代码(使用StopProgram = False
),它会一直持续到Count = v
我希望能够在循环内停止它,我试图在这里做到这一点,但它创建了一个不幸的循环,它毁了程序。
Do Until StopProgram or Count = v? – Jeremy 2014-12-02 15:17:54
为什么你需要** 3 **循环?所有你需要的是一个带退出条件的循环'If ... Then Exit Do' – ja72 2014-12-02 16:15:52