|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Unused variables that really are?!?starting a new one because I have exactly the same problem. The original poster never did get a satisfactory answer because "the problem went away as mysteriously as it arrived". Here's a snippet from my program that illustrates the problem: Select Case reader.Name Case "FName" mySigBlockStruct.FName = reader.ReadString() Case "FNameChecked" Dim I As Integer I = 1 Dim boolTemp As Boolean boolTemp = CBool(reader.ReadString()) In this code, both I and boolTemp are flagged as "Unused Local Variable". I can move the exact same statements to another part of the same Sub and they're not flagged anymore. Anyone have an answer for this?
Show quote
Hide quote
"Seigfried" <Seigfr***@msn.com> schrieb: I have experienced this problem from time to time too.> The original poster never did get a satisfactory answer because "the > problem went away as mysteriously as it arrived". > > Here's a snippet from my program that illustrates the problem: > > Select Case reader.Name > Case "FName" > mySigBlockStruct.FName = > reader.ReadString() > Case "FNameChecked" > Dim I As Integer > I = 1 > Dim boolTemp As Boolean > boolTemp = > CBool(reader.ReadString()) > > In this code, both I and boolTemp are flagged as "Unused Local > Variable". I can move the exact same statements to another part of the > same Sub and they're not flagged anymore. You can try to delete the project's "bin" and "obj" folders and compile it again, maybe this will fix the problem. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Are you using VS2005? You don't get that error in 2003.
What is happening is that your are dimension within the select routine
Show quote
Hide quote
On 21 Apr 2006 14:00:28 -0700, "Seigfried" <Seigfr***@msn.com> wrote: "I" and "boolTemp" as used above only have scope in Case>There was a previous thread with this title that was closed, so I'm >starting a new one because I have exactly the same problem. > >The original poster never did get a satisfactory answer because "the >problem went away as mysteriously as it arrived". > >Here's a snippet from my program that illustrates the problem: > > Select Case reader.Name > Case "FName" > mySigBlockStruct.FName = >reader.ReadString() > Case "FNameChecked" > Dim I As Integer > I = 1 > Dim boolTemp As Boolean > boolTemp = >CBool(reader.ReadString()) > >In this code, both I and boolTemp are flagged as "Unused Local >Variable". I can move the exact same statements to another part of the >same Sub and they're not flagged anymore. > >Anyone have an answer for this? "FNameChecked". Although they are assigned a value, the variables are never read by the app in the above 'case', therefore, they are "unused" or "dead". Gene Thanks for the replies ...
But I don't understand the "Gene Kelley" reply. Select Case reader.Name Case "FName" mySigBlockStruct.FName = reader.ReadString() Case "FNameChecked" Dim I As Integer I = 1 I may have scope only in this one Case, but it's defined and used in only this one Case. It still looks like a bug in VB to me. I was using Visual Basic 2005 Express. I think he means that it was assigned but not referenced, that is
nothing else uses the value you assigned to it so the code checker thinks it's essentially wasted code. Try putting code like dim j as integer j = I after that and see if it now doesn't complain about I anymore. It may complain about j now, but maybe not about I because I is assigned a value and something references the value of I. Just a thought.
Show quote
Hide quote
On 24 Apr 2006 11:09:43 -0700, "Seigfried" <Seigfr***@msn.com> wrote: Where are they "used"? ("used" meaning the varibles are referenced in>Thanks for the replies ... > >But I don't understand the "Gene Kelley" reply. > > Select Case reader.Name > Case "FName" > mySigBlockStruct.FName = >reader.ReadString() > Case "FNameChecked" > Dim I As Integer > I = 1 > >I may have scope only in this one Case, but it's defined and used in >only this one Case. It still looks like a bug in VB to me. > >I was using Visual Basic 2005 Express. some subsequent code while the varibles still have scope). This page may be of interest: http://www.aivosto.com/project/help/problemdetection-deadcode.html Gene
Web Browser in Windows App
TableAdapters and true N-Tier dotnet security exception issues Newbie Question about Value and Reference Types Addhandler with parameter ? Newbie: Examples of ExecuteNonQuery VB2005 structures to file Close a msgbox Dragging Borderless Forms Off topic--best place to ask a question |
|||||||||||||||||||||||