title: Setting the value of a variable in Visual BASIC
body: <p>Hi i'm new in programming world and I've started my programming by Visual BASIC. I'm trying to set a value of a variable through the program closing event and load the same value in program load event. As example:
  At first I tried:</p>
  
  <pre><code>Dim Age as Integer
  Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
  Age = 50
  End Sub
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  Textbox1.text = Age
  End Sub
  </code></pre>
  
  <p>But when I close the program and restart it, it resets to zero.
  Next I tried "Settings" from properties but if I move my program from one location to another then it also resets everything.
  Finally I tried Stream readers and writers to catch the final value but for this I had to attach some text files to the programs which I don't want. Can anyone help me how to solve the following problem with custom class libraries or by something else?</p>