tags:

views:

99

answers:

3

Hello All,

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 showing 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!

A: 

Are you getting 1000 "Done" message boxes?

DanDan
Sort of. Its not actually a Message box... I am logging it. Yes, I am getting 1000 logs.
Ian
The logging is causing a delay? The logging is flushing an io stream? The created integer is uncorrupting the stack?These are all stabs in the dark :) I think you have a tough problem here.
DanDan
A: 

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.

CMH
+1  A: 

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.

Kaniu
I have to agree with Kanju that switching the event would change how the function behaves. But looking at your previous questions on the FreeSid API call your issue with the ByVal may have corrected it all.
Jeff