1

The compiler will show a warning when a variable is declared within a local scope and is not used elsewhere or is used before assigning a value.

  • Why does that not apply to global variables?
  • How can I find unused / unassigned global variables? Is there any other way for this other than Ctrl+F?
Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54
  • 2
    An other way than ctrl-f is: Right-Click on the variable (or property) and then "Find All References", it will give you all the places that use that variable. Take note that if you use any reflection, this will not show up. – the_lotus Dec 15 '14 at 15:29

1 Answers1

0

1] Why does that not apply to global variables?
Its not true. There is no global variables in VB.Net. Check This Link

So, You will not get warning for variables declared as public in VB.Net

2] How can I find unused / unassigned global variables? Is there any other way for this other than Ctrl+F?
Public variables which you are calling Global Variables will not be listed in, So you can use Auto window/Local window/Watch window. But you need to add them to the watch window manually.

Community
  • 1
  • 1
Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54