如何在 VBA / VB.NET 中跳出无限循环

How to escape infinite loop in VBA / VB.NET

有点愚蠢的问题,但我找不到任何答案。
可悲的是,我犯了一个非常可耻的错误,我不小心创建了一个无限循环。

Private Sub Textbox1_Change()
    Do While Len(Trim(Textbox1.Text)) > 4
       MsgBox "Please enter your birthyear in format of ####"
    Loop
End Sub

As I wanted to enforce users to type only 4 digits, obviously not realising I made an given it's impossible to close the MsgBox as once you reach >4 characters, it keeps on creating new MsgBoxes even after you QueryClose/OK the one that popped up.

有什么方法可以取消它,而不用完全关闭 Excel?可悲的是,鉴于 MsgBox 以模式形式打开,我什至无法暂停代码,而且我无法单击任何编辑器元素。

只需按 Ctrl + Alt + Pause/Break

这会打断您的日常工作。

The Pause/Break button is standardly located above the PageUp button on most keyboards