Question

I'm ridding my code of all compiler warnings, as per my bosses request, when I came across some unused local variables. Naturally, I removed the ones which were legitimate, however I stumbled upon a couple which aren't as straight forward. (Variable names changed for security)

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

strAAA is allegedly an 'unused local variable' when it is clearly used directly 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

The warning is still present.

Can anybody solve this mystery?

Était-ce utile?

La solution

Solved it. There was a Return True about 50 lines above. This was always being hit, thus the variables were never being set.

Sloppy code from my predecessor I'm afraid!

Autres conseils

Try eliminating the variable instance...

If FUNCTION_NAME(strTmpFileName, "ViewLet" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc") Then Return True
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top