473,498 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I identify and remove unused variable

Is there a way I identify and remove unused variable within vb2005 standard
edition
Dec 12 '05 #1
3 7159
"Tom McL." <tb***@cwnet.com> schrieb:
Is there a way I identify and remove unused variable within vb2005
standard edition


AFAIK VS 2005 will underline unused /local/ variables automatically and
create compile-time warnings. I assume that this will be supported in the
Standard edition too, but I do not have the Standard edition to check if
this is true.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 12 '05 #2
Tom,

Can you expand upon/clarify what you are trying to achieve?

If you want to find and remove a variable you have declared in code, then
you can try using the VS find tool. Press Ctrl + F to open this. (Note you
can also press Ctrl + H to access the find and replace.)

You can then either Find Next, or mark all instances and skip between them
quickly (using the code bookmark (flag) toolbar), to check how that variable
is being used.

A consideration is the scope and lifetime of the variable. If it is used in
just one procedure, once that procedure has completed, then the variable
goes out of scope and will eventually be taken care of by the framework's
garbage collection (this isn't instant though). You could also override the
issue by setting the variable to nothing at the end of the method. Take a
look at MSDN
http://msdn.microsoft.com/library/de...abletopics.asp
for further info on scope and lifetime.

If the variable is global to your form or application, a cruder method would
be to remove (comment out) the declaration and try to recompile. Any
instance of the variable being used should the appear in the Tasks pane as a
list showing you where the variable is no longer a member of the class. You
can double-click each Task entry to be taken to the code line in question so
you can check how the variable is being used. This approach is a bit
coarse, particularly for larger projects, but it may still help you.

Hope this helps.

Alec
"Tom McL." <tb***@cwnet.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is there a way I identify and remove unused variable within vb2005
standard edition

Dec 12 '05 #3
Tom McL. wrote:
Is there a way I identify and remove unused variable within vb2005
standard edition


If it doesn't behave as Herfried suggests, you might be able to identify
them with FxCop (http://gotdotnet.com/team/fxcop/). Removal would be by
manual editing.

Andrew
Dec 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3370
by: ralphNOSPAM | last post by:
Is there a PHP script that can find unused variables? I'd like to 'clean up' my scripts. Thanks...
2
4409
by: Andreas D. Bauer | last post by:
Hello is there a tool (add in, etc.) with can be used to identify objects with are not used in the currend database?
3
3059
by: Apollo440 | last post by:
How to remove unused using directive? eg) using System; using System.Windows.Forms; <- i want to remove this unused using directive namespace foo { :
2
3997
by: AussieRules | last post by:
Hi, There use to be some 3rd party tools that would remove unused subs and function and unused code from vb projects. Is there are a way to do this in vb.net 03
12
9587
by: zacks | last post by:
Suddenly, in a VB2005 project I am working on, several variables show up in the list of warnings are being unused local variables. But they all are. Several of them are the ex variable used in a...
9
1724
by: Martijn Mulder | last post by:
A nice feature of the csc.exe compiler is that it warns you if a variable is declared but never used. But unused methods are not flagged, even when the warning level is set to 4.
31
8563
by: smachin1000 | last post by:
Hi All, Does anyone know of a tool that can automatically analyze C source to remove unused #includes? Thanks, Sean
9
5478
by: werasm | last post by:
Hi all, I'm looking for a nice clean (portable) way to get rid of unused variable warnings without fiddling with compiler settings (on a per case basis). I've come up with this: template...
2
1815
by: newbie | last post by:
Is there a tool to identify used / unused styles in a stylesheet? I have a tendency to accumulate styles in a stylesheet. Many of these styles are not actually employed by the page, so many of...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.