ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Debug Step vs Run Mode (https://www.excelbanter.com/excel-programming/281966-debug-step-vs-run-mode.html)

Arthur[_3_]

Debug Step vs Run Mode
 
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

Bob Phillips[_5_]

Debug Step vs Run Mode
 
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)

"Arthur" wrote in message
...
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[_3_]

Debug Step vs Run Mode
 
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


-----Original Message-----
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)

"Arthur" wrote in

message
...
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



.


Tom Ogilvy

Debug Step vs Run Mode
 
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.
--
Regards,
Tom Ogilvy


Arthur wrote in message
...
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


-----Original Message-----
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)

"Arthur" wrote in

message
...
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



.





All times are GMT +1. The time now is 03:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com