Solved

How to detect unused variables?

Posted on 2000-02-15
6
918 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

786 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