Solved

How to detect unused variables?

Posted on 2000-02-15
6
961 Views
Last Modified: 2008-03-03
Hello experts.
I have 2 questions:

1: I remember when I compile C programs using cc compiler it tells me whether I have un-used variables.

Is there a similar thing in VB?

2: I sometimes declare variables without a viariable type ie..

dim aString
dim aInt


which will set the variables to type Variant.

When i do this, it would be by mistake, is there a way to get the compiler to tell me this?


Thanks


Kaiser

0
Comment
Question by:kaiser18au
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 2525240
See the tools here. They are free and Project Analyzer has the feature of detecting unused variables and mismatches like your example. http://www.aivosto.com/visdev/
0
 

Author Comment

by:kaiser18au
ID: 2528991
Mirkwood:

Thanks for the answer. I checked out the website and
it was good. But the only had solutions to Q1.

If you dont mind I would like to keep this question open to see if people have suggestions for Q2.


If there is nothing else, then you could have the points.


Regards


kaiser
0
 
LVL 6

Expert Comment

by:VBGuru
ID: 2530285
Q2. There is no way a compiler can do this. Compiler will check for the syntax and as per the syntax it is a valid. So it will continue without any problem.

You can take a precaution using
DefBool DefByte DefInt DefLng DefCur
DefSng DefDbl DefDec DefDate DefStr ...

May be you cam write an add-in to check for these kind of declarations
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:VBGuru
ID: 2530286
Q2. There is no way a compiler can do this. Compiler will check for the syntax and as per the syntax it is a valid. So it will continue without any problem.

You can take a precaution using
DefBool DefByte DefInt DefLng DefCur
DefSng DefDbl DefDec DefDate DefStr ...

May be you cam write an add-in to check for these kind of declarations
0
 

Author Comment

by:kaiser18au
ID: 2532848
Mirkwood:

Sorry about that, that websites software did have that feature.

If you want to put in another answer, then I can forward you the points.

It was just a feature that was hidden, you had to pop up the options thats all.

Thaks again.

kaiser
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 20 total points
ID: 2537059
Ok, thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 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