473,386 Members | 1,883 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,386 software developers and data experts.

"variable 'x' declared but never used" warnings in VB.NET

Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to be
3 or above.

In the same solution, I also have a VB project, however Help document
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpropertieswarni nglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but unused
variables in my VB.NET code?

Thanks
Harry
Jul 21 '05 #1
8 5680
Remove the variable. If its never used, why have it in ?, I note that the
vairable is 'ex', if this is an exception in a try catch block, then either
put some implementation in there to stop the message or remove the try catch
completely as it is serving no purpose.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to be 3 or above.

In the same solution, I also have a VB project, however Help document
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpr
opertieswarninglevel.htm says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but unused variables in my VB.NET code?

Thanks
Harry

Jul 21 '05 #2
Hi,
Assuming I understood your question correctly: changing the warning level of
a Visual Basic .NET project will not affect C# Project warning level. So,
change the warning level of the C# project to something less than 3 to avoid
this warning.

With respect to the addins to detect unused variables, the tool Total .NET
analyzer (www.fmsinc.com) does that check (in addition to other code
checks).

HTH

"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to be
3 or above.

In the same solution, I also have a VB project, however Help document
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpr
opertieswarninglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but unused
variables in my VB.NET code?

Thanks
Harry

Jul 21 '05 #3
> Remove the variable. If its never used, why have it in ?,

LOL
Jul 21 '05 #4
Hi Harry

I'm not sure how my colleagues here have come to misunderstand your
question, but for everyone perhaps I can provide my own interpretation:

You have a program containing both C# and VB.NET code. The C# compiler
helpfully tells you of variables that are declared but not used, so that you
can remove them. The VB.NET compiler is not so helpful.

I'm sure you would remove the unused variables, if the compiler would be so
good as to tell you where they are ;-)

The de facto standard (perhaps because it is free) seems to FxCop, at

http://www.gotdotnet.com/team/fxcop/

HTH

Charles
"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to
be 3 or above.

In the same solution, I also have a VB project, however Help document
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpropertieswarni nglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but
unused variables in my VB.NET code?

Thanks
Harry

Jul 21 '05 #5
> The de facto standard (perhaps because it is free) seems to FxCop, at

http://www.gotdotnet.com/team/fxcop/

Hi Charles,

It is freely available, but it is a product in one sense: it has a dedicated
team of individuals within Microsoft who do nothing else but work on this
product. Microsoft isn't just being generous. They use FxCop internally to
perform static analysis of their own code before releasing it to the general
public.

--- N
Jul 21 '05 #6

Thank you Charles.
"Charles Law" <bl***@nowhere.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi Harry

I'm not sure how my colleagues here have come to misunderstand your
question, but for everyone perhaps I can provide my own interpretation:

You have a program containing both C# and VB.NET code. The C# compiler
helpfully tells you of variables that are declared but not used, so that
you can remove them. The VB.NET compiler is not so helpful.

I'm sure you would remove the unused variables, if the compiler would be
so good as to tell you where they are ;-)

The de facto standard (perhaps because it is free) seems to FxCop, at

http://www.gotdotnet.com/team/fxcop/

HTH

Charles
"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to
be 3 or above.

In the same solution, I also have a VB project, however Help document
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpropertieswarni nglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but
unused variables in my VB.NET code?

Thanks
Harry


Jul 21 '05 #7
OHM,
You can also have just the Catch without a variable defined.

Try
SomethingNew()
Catch
' I really don't want to do any thing here
' Yet I don't want others to know that
' SomethingNew failed
End Try

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Remove the variable. If its never used, why have it in ?, I note that the
vairable is 'ex', if this is an exception in a try catch block, then
either
put some implementation in there to stop the message or remove the try
catch
completely as it is serving no purpose.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs to

be
3 or above.

In the same solution, I also have a VB project, however Help document

ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpr
opertieswarninglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but

unused
variables in my VB.NET code?

Thanks
Harry


Jul 21 '05 #8
Do you know, I never tried that construct configuration before, as I have
allways implemented the handling, interesting to know though.

Thanks
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Om*************@tk2msftngp13.phx.gbl...
OHM,
You can also have just the Catch without a variable defined.

Try
SomethingNew()
Catch
' I really don't want to do any thing here
' Yet I don't want others to know that
' SomethingNew failed
End Try

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl...
Remove the variable. If its never used, why have it in ?, I note that the vairable is 'ex', if this is an exception in a try catch block, then
either
put some implementation in there to stop the message or remove the try
catch
completely as it is serving no purpose.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"harry" <harry@nospam> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
Hi,

During compilation, a C# project in my solution triggers the following
warning:

"warning CS0168: The variable 'ex' is declared but never used"

To trigger this warning, it appears the C# compiler WarningLevel needs
to be
3 or above.

In the same solution, I also have a VB project, however Help document

ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectconfigurationpr opertieswarninglevel.htm
says VB maximum WarningLevel is 1.

Is there a workaround? or
Does anyone know of an addin or tool to help me identify declared but

unused
variables in my VB.NET code?

Thanks
Harry



Jul 21 '05 #9

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

Similar topics

40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
2
by: ~~~ .NET Ed ~~~ | last post by:
It is not the first time I see this happen. I am using VS.NET 2003 with .NET Framework 1.1. In this particular situation I have a custom user control in a windows form. There is a member variable...
9
by: harry | last post by:
Hi, During compilation, a C# project in my solution triggers the following warning: "warning CS0168: The variable 'ex' is declared but never used" To trigger this warning, it appears the C#...
3
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from...
7
by: What-A-Tool | last post by:
In the following code, "catch" is underlined in blue, and the error "the variable fx is declared but never used" is displayed when I mouse hover over it. Am I doing something wrong, or do I just...
3
by: Yansky | last post by:
If I have the following code: var abc; if(!abc){ alert('test'); }
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.