Debug Step vs Run Mode

  • Thread starter Thread starter Arthur
  • Start date Start date
A

Arthur

SubB is called from SubA. My problem is the return to SubA
seems to occur prematurely - before executing all the code
in SubB. I cannot see anything in SubA or SubB to cause
this.

I placed a messagebox as the last line of code in SubB
just to see if it was getting there. Sure enough - no
Messagebox pops up in runtime. Aha, now I'm on to
something, right?

To debug it further, I placed a breakpoint at Call SubB,
and stepped the rest of the way through SubB. Here's what
happens - EVERY LINE of SubB code executes in step mode,
right up through the messagebox. Honest!

I'm baffled. Any ideas?

Art
 
Arthur,

Do you have any error handling that causes it to bypass code?

Post the code and give details.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob, there is no error handling. The code is rather
lengthy to post. I'll have to see if I can pull out the
relevant pieces. Thanks for your interest. Have you ever
encountered a situation that behaved differently in
runtime vs. step mode?

Art
 
Yes, especially if the code is in a sheet level module.

This duplicates the kind of behavior you describe:

Sub SubA()
On Error Resume Next
vval = 1
vval = 2
subb
vval = 4
vval = 5
MsgBox "end of suba"
End Sub

Sub subb()
vval = 1
vval = 2
vval = 3 / 0
MsgBox "end of subb"
End Sub

You may say you don't use error handling, bug do you have on error resume
next?

Do you use

if condition then exit sub

actual execution versus step mode can cause things to be evaluated
differently if the code depends on the environment.
 
Back
Top