문제

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?

도움이 되었습니까?

해결책

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!

다른 팁

Try eliminating the variable instance...

If FUNCTION_NAME(strTmpFileName, "ViewLet" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc") Then Return True
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top