Solved

How to detect unused variables?

Posted on 2000-02-15
6
943 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
  • 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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