title: What are the differences between Shared and Static?
body: <p>I'm a C# developer but I've inherited a legacy VB app today with 0 documentation what so ever. I've been starting to read through the code and reference the <a href="http://msdn.microsoft.com/en-us/library/ksh7h19t(v=vs.90).aspx" rel="noreferrer">list of VB keywords</a> every 5 seconds.</p>
  
  <p>I guess I don't understand the distinction between <code>Shared</code> and <code>Static</code>.</p>
  
  <p>Reading this post: <a href="https://stackoverflow.com/a/1980293/1189566">https://stackoverflow.com/a/1980293/1189566</a></p>
  
  <p>It states:</p>
  
  <blockquote>
    <p>VB doesn't have <code>static</code>, it has <code>shared</code></p>
  </blockquote>
  
  <p>But you can see in the list of keywords linked above, <code>Static</code> is a reserved keyword. It looks like <code>Static</code> is only applicable to fields, where as <code>Shared</code> can be on a method <strong>or</strong> a field?</p>
  
  <p>I guess ultimately I'm just hoping someone could expand upon the answer I linked to provide some more details for a VB noob.</p>
  
  <p>For example, say I had this</p>
  
  <pre><code>public class MyClass
      Dim myVar as Integer = 1
  
      public shared sub UpdateMyVar()
          myVar = 2
      end sub
  end class
  
  public class MyOtherClass
      Dim cOne = New MyClass()
      Dim cTwo = New MyClass()
  
      cOne.UpdateMyVar()
      txtMyTextBox.Text = cTwo.myVar.ToString()
  end class
  </code></pre>
  
  <p>Please forgive any syntactical issues. Assume this code compiles. I've literally just started skimming the code an hour and a half ago.</p>
  
  <p>Would <code>cTwo.myVar</code> be <code>1</code> or <code>2</code>? I'm guessing <code>2</code> since <code>Shared</code> seems to affect all instances of a class? That seems tremendously dangerous.</p>