Reputation: 380
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?
Upvotes: 8
Views: 3902
Reputation: 380
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!
Upvotes: 11
Reputation: 6764
Try eliminating the variable instance...
If FUNCTION_NAME(strTmpFileName, "ViewLet" & strBBB & Now.ToString("yyyyMMddHHmmss") & ".doc") Then Return True
Upvotes: 0