Within a macro I call a function with the parameters a, b and c.
The definition of the function has parameters d, e and f.
In order to debug it, do I need to put a watch on a, b and c or on d, e and f?
Printable View
Within a macro I call a function with the parameters a, b and c.
The definition of the function has parameters d, e and f.
In order to debug it, do I need to put a watch on a, b and c or on d, e and f?
Quote:
Originally Posted by pickarooney
What do you mean by "watch"?
What I normally do when debugging is to add MsgBox and then the variable to be checked at various points through the routing - that way you can tell any results that should not be there.
Can you elaborate on your porblem?
Cheers,
RyanJ
From the IDE, click Debug/Add WatchQuote:
Originally Posted by sciguyryan
At least, that is the way it is in VB. I've no idea about Excel (and, because you use the term "macro", I'm assuming you are using Excel VBA not VB)
Sorry, I should have specified it was a Word VBA macro. I assumed the IDE was the same. It seems I need to put watches on the d,e and f variables, going by the results I'm getting so far.
It all depends on what you actually want to watch and how the arguments (or parameters) are passed to your function, ByVal or ByRef. If they are passed ByVal the function can not change the origional variables values. Do you want to watch them while the function is running? In that case you need to watch the d, e, and f, but if you want to watch what has happen with the origional variables when the function has returned you must of course watch the a, b, and c variables.