Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default How to knwo the current statement

Hi all,

Sometimes, application breaks at an execution point and this execution point
is the next statement, so how can I find the just previously executed
statement? This may sound obviating in a sequence execution case, but what
about in blocks of IF ...ELSEIF case?

Clara
--
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default How to knwo the current statement

"clara" wrote in message
...
Sometimes, application breaks at an execution point and this execution
point
is the next statement, so how can I find the just previously executed
statement? This may sound obviating in a sequence execution case, but what
about in blocks of IF ...ELSEIF case?


Hi Clara,

There's no automatic way to figure this out that I'm aware of. You can
do one of two things. The simplest and most reliable would be to place a
break point before the whole block of code that you are interested in and
then step through it manually to determine which path the code takes.

The other option is to examine the values of all the relevant control
variables and expressions while still in break mode and use that to infer
which path the code took to get where it currently is. The problem with this
method is that it's quite possible for your code to change the state of
these variables and expressions such that it's no longer possible to
reliably determine the previous execution path.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to knwo the current statement

There's no automatic way to figure this out that I'm aware of. You can
do one of two things. The simplest and most reliable would be to place a
break point before the whole block of code that you are interested in and
then step through it manually to determine which path the code takes.


Another technique that I like to use is to place Debug.Print statements at
the key points in the execution path having them print out (to the Immediate
window) location and and variable information. As an example....

Debug.Print "I'm in MySub; MyVariable = " & MyVariable

These Debug.Print statements can be anywhere in your code (event procedures,
functions, etc.) allowing you to run your code to the break point and then
simply read where you have been and what any key variables were along the
way.

I usually place the Debug.Print statements flush-left so that stand out
against my indented code making them easy to find when the debugging session
is over and I want to remove them.

Rick

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default How to knwo the current statement

Hi Rob,

i like your second method better because it is at least a semi-automatic way.
I read your Professional Excel Development book, in Chaper 16 VBA Debugging
on page 553, you wrote"Having a clear marker on the line of code that will be
executed next tends to be much more valuable than having a marker on the line
of code you just executed. The latter is easily determinded from the former,
but not necessarily vice versa"
Could you explain it again here?

Clara
--
thank you so much for your help


"Rob Bovey" wrote:

"clara" wrote in message
...
Sometimes, application breaks at an execution point and this execution
point
is the next statement, so how can I find the just previously executed
statement? This may sound obviating in a sequence execution case, but what
about in blocks of IF ...ELSEIF case?


Hi Clara,

There's no automatic way to figure this out that I'm aware of. You can
do one of two things. The simplest and most reliable would be to place a
break point before the whole block of code that you are interested in and
then step through it manually to determine which path the code takes.

The other option is to examine the values of all the relevant control
variables and expressions while still in break mode and use that to infer
which path the code took to get where it currently is. The problem with this
method is that it's quite possible for your code to change the state of
these variables and expressions such that it's no longer possible to
reliably determine the previous execution path.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default How to knwo the current statement

"clara" wrote in message
...
i like your second method better because it is at least a semi-automatic
way.
I read your Professional Excel Development book, in Chaper 16 VBA
Debugging
on page 553, you wrote"Having a clear marker on the line of code that will
be
executed next tends to be much more valuable than having a marker on the
line
of code you just executed. The latter is easily determinded from the
former,
but not necessarily vice versa"
Could you explain it again here?


Hi Clara,

That statement was quite simply wrong and I have no idea what I was
thinking when I wrote it. I plan on removing it from the second edition of
PED which we are working on now and hope to have published sometime early
next year.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default How to knwo the current statement

Thanks Rob
--
thank you so much for your help


"Rob Bovey" wrote:

"clara" wrote in message
...
i like your second method better because it is at least a semi-automatic
way.
I read your Professional Excel Development book, in Chaper 16 VBA
Debugging
on page 553, you wrote"Having a clear marker on the line of code that will
be
executed next tends to be much more valuable than having a marker on the
line
of code you just executed. The latter is easily determinded from the
former,
but not necessarily vice versa"
Could you explain it again here?


Hi Clara,

That statement was quite simply wrong and I have no idea what I was
thinking when I wrote it. I plan on removing it from the second edition of
PED which we are working on now and hope to have published sometime early
next year.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Current year and current week number Grey Old Man[_2_] Excel Discussion (Misc queries) 11 December 8th 09 06:30 PM
Can I automatically enter the current date or current time into a Ben New Users to Excel 7 October 19th 05 03:38 PM
Current time Current date. yo beee Excel Programming 3 July 22nd 04 03:41 AM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM
Best Way to Modify current IF() statement?????? WebWizard97 Excel Programming 4 September 23rd 03 07:50 PM


All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"