title: Value of global variable won't change
body: <p>I have a variable whose scope needs to be global, because it needs to be called in a function as well as in a button press. So I declared the variable in a Module so it would be global.</p>
  
  <p>The problem is that the value of this variable needs to be equal to the value of the text property of a textbox in the form.</p>
  
  <p>Here you can download the VB.net demonstration of my problem: <a href="http://db.tt/DDxQJDXl" rel="nofollow">http://db.tt/DDxQJDXl</a></p>
  
  <p>Below is an explanation of what happens</p>
  
  <p>You enter a string into the textbox, in this case I entered "Hello". Then you click the button and it displays what you wrote.</p>
  
  <p><img src="https://dl.dropboxusercontent.com/u/41629841/Online%20Posts/StackOverflow/8608854/Press1.PNG"/></p>
  
  <p>You click OK in that message box and change the value in the textbox. In this case I changed it to "Goodbye". Then I hit the button again, but the variable did not change values and the messagebox displays "Hello" again.</p>
  
  <p><img src="https://dl.dropboxusercontent.com/u/41629841/Online%20Posts/StackOverflow/8608854/Press2.PNG"/></p>
  
  <p>Here is the entire source code:</p>
  
  <pre><code>Module Module1
       Public strDataValue = frmTest.txtDataValue.Text
  End Module
  Public Class frmTest
      Private Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click
          MsgBox(strDataValue)
      End Sub
  End Class
  </code></pre>
  
  <p><strong>Note:</strong> This is just a demonstration of a problem I'm having in a much larger program so the variable <em>does</em> have to be global.</p>