Unused local variables (Visual Studio 2012)

I get rid of the code for all compiler warnings, as is the case with my boss when I came across some unused local variables. Naturally, I deleted those that were legal, but I came across a couple that is not so straightforward. (Changed names changed for security)

Dim strAAA As String = "aaaa" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc" If FUNCTION_NAME(strCCCC, strAAA) Then Return True 

strAAA is supposedly a "unused local variable" when it is explicitly used immediately below.

Even when I write it as follows:

 Dim strAAA As String strAAA = "ViewLet" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc" If FUNCTION_NAME(strTmpFileName, strAAA) Then Return True 

A warning is still present.

Can anyone solve this mystery?

+7
compiler-warnings visual-studio-2012
source share
2 answers

I decided. There was Return True about 50 lines above. It always hit, so the variables were never set.

Incorrect code from my predecessor, I'm afraid!

+10
source share

Try to exclude an instance of a variable ...

 If FUNCTION_NAME(strTmpFileName, "ViewLet" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc") Then Return True 
0
source share

All Articles