Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to write an Add-in to find the useless variables

Posted on 2000-04-28
7
Medium Priority
?
184 Views
Last Modified: 2010-05-02
Hi,

How to write an Add-in or anything to find
1. the declared variables never be used in the program,
2. the variables assigned value but never be used,
3. anything similar you think we should do.
0
Comment
Question by:username1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:morpho
ID: 2759221
Thats a biggie - I suspect you might need to offer more than 70 pts.

Keep your eyes peeled on www.morpho.co.uk - I'm just completing a tool to do that among other things - I'll post the source when finished !
0
 
LVL 2

Expert Comment

by:Sage020999
ID: 2759343
Here is the site I posted for you yesterday on your other question.  I think that this will be the simplest way:  http://vb-world.net/articles/addins/    hope this helps.
0
 

Expert Comment

by:morpho
ID: 2759658
Creating an add-in is the straightforward bit. Determining what has or hasnt been used is a different kettle of fish entirely !
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Accepted Solution

by:
Sage020999 earned 210 total points
ID: 2759713
After you fiqure out how to write an add-in, you will need to use the active code panes to search for any Dimmed varibles.  You will need some sort of function that determines if the varible is a field name, varible name, comment, or a function call.  The comments are the easiest to solve.  Any lines beginning with the single quote ', you would ignore. Any Varibles following the DIM statement you would want to stick in an array.  It is important to remember scoping here.  You will have the potential of having a Public varible named the same as private varibles.  Once you have your array, you will want to search for the whole word that matches the varible name.  This will exclude field names which are either formatted ('Field'),!Field, or [Field].  Everything else is a varilbe being used.  You then want to have a counter to count the times the varible is found within the scope.  Once you find it once, you can move to the next varible.  This is not an easy task and will take some time.  These are one of those tasks that cost more to do than purchase, but would be rewarding after the completion of the project.  Good Luck. I hope this helps a little.  -Sage.  This is an interesting topic, I hope you receive some feed back from people who have done simular tasks.  I have created multiple clip boards, modified text, but as far as searching for unused varibles, I purchased VBCompress Pro.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 2759975
Could be done as an add-in or as a stand alone project.  As a stand alone, you would use the project file to find out which files to parse and then do what Sage says above.  

Also, you might want to consider creating a call tree of routines to find dead code.  Variables used in dead code are not really used.

Basically, you would need to trace any routine (Sub, Function or Properties) called from startup modules and/or user-interface and follow any routines called from those etc.

Then any routines that are left over could be flagged as dead and displayed in a list to the user.

This is a big project, good luck!

0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2761008
You'll also need to keep track of functions with the same name as variables, variables declared with type identifiers (!, %, $, #), multiple variables dimensioned on single lines etc,etc etc

I have an application developed in-house and if I can persuade the author to let me publish I'll do so, but its too large to publish here. I'll try and post it on a web site somewhere  (as I understand its against house-rules to e-mail answers to individuals).
0
 

Author Comment

by:username1
ID: 2764150
Hi,

Thank you for all experts who gave me usefull suggestions.

This is not as easy as I thought....if VB7 or VB2000 wont do this and I have spare time, I will try :-)

Cheers.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question