473,385 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unused variables that really are?!?

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 Try/Catch, and
the Catch for each one references the ex exception variable. Yet it is
still flagged as unused? What gives?

Dec 12 '05 #1
12 9575
Are you referencing the exception variable in the catch block? I am guessing
not, which is why it is flagged that awy.

<za***@construction-imaging.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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 Try/Catch, and
the Catch for each one references the ex exception variable. Yet it is
still flagged as unused? What gives?

Dec 12 '05 #2
<za***@construction-imaging.com> schrieb:
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 Try/Catch, and
the Catch for each one references the ex exception variable. Yet it is
still flagged as unused? What gives?


I'm not able to repro the problem you describe with the final version of VS
2005. Which veryion are you using? Does the problem even occur in a newly
created project? Could you post the code you are using? Maybe deleting the
project's "bin" and "obj" folders and recompiling solves the problem.

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

Dec 12 '05 #3
Zacks,

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 Try/Catch, and
the Catch for each one references the ex exception variable. Yet it is
still flagged as unused? What gives?

It is a new feature what some of us by instance (Herfried and I) are not
completly fond of.

(As far as I have seen does it work correct by the way, however it does not
know that you as human know that some situations cannot exist).

Do not try to create constructions as this.

dim mystring as string = "".

This gives only overhead.

Cor
Dec 12 '05 #4
I would not even have a Catch block if I did not reference the
exception variable.

Dec 12 '05 #5
Sure you can. It will catch all exceptions.

The following compiles just fine:

Try
Catch
End Try

It is functionally the same as

Try
Catch ex As Exception
End Try

<za***@construction-imaging.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I would not even have a Catch block if I did not reference the
exception variable.

Dec 12 '05 #6
VS 2005 Version 8.0.50727.42

I have not n oticed this situation in a new project. In fact, it just
cropped up today in a project I have been working on for the past
month.

Deleting the bin and obj folders and rebuilding did not help.

Sorry, I can't post any of the code, my company owns it. I can post the
warning the compiler tells me about these variables:

Warning 5 Unused local variable: 'KeyField'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 140 13 Universal Data Mover
Warning 6 Unused local variable: 'OrderBy'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 141 13 Universal Data Mover
Warning 7 Unused local variable: 'DerivedValue'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 143 13 Universal Data Mover
Warning 8 Unused local variable: 'StillAdding'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 148 13 Universal Data Mover
Warning 9 Unused local variable: 'DoUpdate'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 149 13 Universal Data Mover
Warning 10 Unused local variable: 'KeyChanged'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 150 13 Universal Data Mover
Warning 11 Unused local variable: 'VerificationErrors'. C:\Documents
and Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 151 13 Universal Data Mover
Warning 12 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 253 15 Universal Data Mover
Warning 13 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 279 19 Universal Data Mover
Warning 14 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 317 19 Universal Data Mover
Warning 15 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 350 19 Universal Data Mover
Warning 16 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 431 23 Universal Data Mover
Warning 17 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 459 23 Universal Data Mover
Warning 18 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 498 23 Universal Data Mover
Warning 19 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 545 23 Universal Data Mover
Warning 20 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 765 35 Universal Data Mover
Warning 21 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 774 35 Universal Data Mover
Warning 22 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 815 51 Universal Data Mover
Warning 23 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 827 51 Universal Data Mover
Warning 24 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 935 51 Universal Data Mover
Warning 25 Unused local variable: 'ex'. C:\Documents and
Settings\zacks\My Documents\CIS\SourceSafe Working\Universal Data
Mover\Universal Data Mover\Data_Engine.vb 946 51 Universal Data Mover

In EACH case, the variable flagged as not sure is most definitely used.

Dec 12 '05 #7
How do I get rid of the warnings?

How can one do:

dim mystring as string = ""

without the overhead you mention?

Dec 12 '05 #8
I know you can. It's just that every time I use a Try/Catch is because
I want to know what the error is.

Dec 12 '05 #9
<za***@construction-imaging.com> schrieb:
How do I get rid of the warnings?

How can one do:

dim mystring as string = ""

without the overhead you mention?


\\\
Dim s As String = Nothing
///

However, I tend to disable the warning as it doesn't make much sense to me.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 12 '05 #10
za***@construction-imaging.com wrote:
How do I get rid of the warnings?

How can one do:

dim mystring as string = ""

without the overhead you mention?

It's only a warning, kind of like those overkill message the newer
versions of Word give you. It's MS's way of being helpful. But since
they aren't errors, and you are sure there is nothing going on that you
aren't already intending, then just ignore the warnings as meaningless.

Tom
Dec 12 '05 #11
Zacks,
I've noticed this in one of my projects that I converted from VS 2003,
however I could not isolate the cause, nor am I able to reproduce the
problem.

About the only unique thing I noticed is that I had numerous other errors &
warnings in the project. Plus I was experiencing severe RAM cram on that
machine, as it was a substantial multi-project solution where each project
was itself fairly large.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<za***@construction-imaging.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
| 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 Try/Catch, and
| the Catch for each one references the ex exception variable. Yet it is
| still flagged as unused? What gives?
|
Dec 12 '05 #12
This problem actually went away as suddenly and mysteriously as it
appeared.

Dec 13 '05 #13

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

Similar topics

35
by: Geronimo W. Christ Esq | last post by:
Are there any scripts or tools out there that could look recursively through a group of C/C++ source files, and allow unreferenced function calls or values to be easily identified ? LXR is handy...
7
by: ralphNOSPAM | last post by:
Is there a PHP script that can find unused variables? I'd like to 'clean up' my scripts. Thanks...
11
by: Michael B Allen | last post by:
Is there a standard method for supressing warnings regarding unused parameters? I have a function that might be called hundreds of thousands of times that looks like this: const void *...
6
by: Seigfried | last post by:
There was a previous thread with this title that was closed, so I'm starting a new one because I have exactly the same problem. The original poster never did get a satisfactory answer because...
9
by: ThazKool | last post by:
I am just wondering if all the methods that are never called upon during a programs execution are removed when optimizing. For example you have: class FooA { void a(); ... void z(); }
2
by: skip | last post by:
At work we have a fairly large application (about 20 packages, 300+ modules) that looks like we might be heading into a bit of a plateau stage. Now seems like a good time to identify and delete...
4
by: Rob Meade | last post by:
Hi all, I'm using Visual Studio 2005 and it has as you are probably aware a very handy feature of reporting to you which variables are not being used - cool thanks... What would be even more...
9
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...
10
by: Joris Dolderer | last post by:
Hello, I want to compile and link a program statically against the dietlibc. Of course, the dietlibc includes functions my program never needs. Is there any way to throw them out of the final...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.