Reputation: 660
I have a very large piece of code written in VBA (>50,000 lines - numerous modules). There is one array of interest to me, and I'd like to find all the conditions under which the value of any element of this array changes. The values can change in any module. Running the script line by line is not the most efficient option due to the size of the code.
I am looking for better ways to solve this problem. Two ways that come to my mind is to programmatically set a breakpoint (which I am not sure if can be done) or programmatically insert an if-block after each assignment that somehow alerts me that the value has changed. (not preferred).
So my question boils down to:
UPDATE: Thanks for the comments/replies. As I had implied, I am interested in the least amount of modification to the current code (i.e. inserting if-blocks, etc) and most interested in the break-point idea. I'd like to know if it's doable.
Upvotes: 12
Views: 20770
Reputation: 5219
There are Two Ways to do that:
Use Stop Key word. Example as given below, set a break point at Stop
if (x = 21 ) Then
Stop
End If
Go to Debug -> Select Add Watch
Upvotes: 9
Reputation: 18889
Use the keyword STOP
to break te code if a certain condition is true.
Upvotes: 17
Reputation: 41
NB:I know this is an old topic but this could help others.
You could use Watches:
Right click on the variables you wish to monitor -> Add Watch... In Watch Type: 'Break when value changes'
While you run your code, you can check the status of your Watches thanks to the Watch Window (accessible from the 'View' menu)
Upvotes: 4
Reputation: 11
in the hope someone can benefit from this : In such situations regardless of the programming language used - writing a few lines of code either in Perl, AWK or even shell scripts can solve the problem : search for a regular expression containing the array name (ignoring case). Once you export all modules and classes in the Workbook(s) into a given directory - the scripts can search those for you.
Upvotes: 1