Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

debugging

  Asked By: Ibthaj    Date: Sep 29    Category: MS Office    Views: 1128
  

I am writing a macro as I have done many times before but when I go to
debug and step through each line of code, I can't see the value of the
variables as I put the cursor over the variable. Anybody know what I
may have changed?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Madeeha Malik     Answered On: Sep 29

This is called hovering (like a helicopter does). I have noticed
some variability in this feature.
First, I *think* the code  has to be run then halted for hovering to
work -- because values have to be assigned to be visable -- I could be
wrong.
In Excel 97, which I use, I don't think I see values upon a hover
except in the procedure where the break occured. Are you outside the
procedure in which the code was halted?
I also think that if I do an actual select in another procedure, it
won't display upon a hover in the original sub.
I also notice that (sometimes) I can see a value while hovering in
the immediate window.
I haven't examined these behaviors carefully to see it it is an
operator thing or VBA or the phase of the moon.

 
Answer #2    Answered By: Aaminah Khan     Answered On: Sep 29

The variables have a scope. If they are declared in a procedure (rather than
in a module before the procedure declaration for example) then they are
created on entry to the procedure and "destroyed" on exit. So not only do
they not have a value outside of the context of the running procedure, but
they actually don't exist. i.e have no memory allocated to them.
If the hover does not work you can always open the immediate window (Ctrl G)
and print the variable  value with *? variable name. *Not as convenient as
the hover option, but viable. Of course there is also the option to set a
watch on a variable and to see the changing value in the watch window.
Hope this helps some.

 
Answer #3    Answered By: Anne Powell     Answered On: Sep 29

I also have never
bothered to check out the behaviour.

Good one actually! If anyone knows the whys and wherefores please do chip
in!!!

OTOH... You can always put  the variable  into the watch window. Selecting or
clicking in it so the cursor  is in the name, and hitting Shift F9 will also
give a value but if it's a long string it's sometime tricky to see the whole
thing.

 
Answer #4    Answered By: Tate Thompson     Answered On: Sep 29

The scope may be (part) of the key to the
apparent strange behavior. I think that's whi I like everyting to
be global.


> OTOH... You can always put  the variable  into the watch window.
Selecting or clicking in it so the cursor  is in the name, and hitting
Shift F9 will also


I haven't gotten comfortable with the Watch yet. I Debug.Print the
begeebers out of my code. Add and remove as needed. Done well, it's
pretty to all the steps progress in the Immediate window as you do
tings. It's an art, however; otherwise you can get *more* confused by
all the stuff you put in the Immediate window.

 
Answer #5    Answered By: Charlie Evans     Answered On: Sep 29

I quite like the watches because there's a limit on the space in the
immediate widow that I've hit a number of times.

It's great to step through the code  and watch that variable  change. I use
dual monitors as well so I can see what's happening on the sheet too. I like
that I don't have to fiddle with the code... Just delete the watches.

If I remember correctly, I sent code a while back to Bear remove all
Debug.Print code from the code... If you er.. get what I mean. Want me to
look it out?

OTOH I guess you could globally change Debug.Print to 'Debug.Print

 
Didn't find what you were looking for? Find more on debugging Or get search suggestion and latest updates.




Tagged: