开发者

VB6 For Loop on error behavior

In VB6, I have the following line of code in the Form_Load event:

DOSOMETHING()
MsgBox "Done"

DOSOMETHING() is a buggy function that I expect to always crash. When I run the app, it will do its thing and crash, without sh开发者_如何学Goowing the MsgBox.

But when I write it using loops:

Dim X as Integer

For X = 0 to 1000
    DOSOMETHING()
    MsgBox "Done"
Next X

The application will not crash, ever. I thought that this has something to do with delays, so I also tried to add a SLEEP inside the loop, to no avail.

So my question is, Is there a special "On Error Resume Next" inside a For loop in VB6?

PS:

If anyone is curious about why I'm asking this, I am trying to reproduce an intermittent bug by calling the function multiple times. Said function is used to check for Administrator function. More detail about the function here.

Thanks!


I't might have something to do with the fact it's called from Form_Load. Perhaps some initialization later in Form_Load or in Form_Activate causes it not to crash.


Try inserting DoEvents after the call to DoSomething. This yields to the o/s, allowing events in its queue to be processed and may enable the function to complete, or fail! before returning to its calling parent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜