title: Storing and keeping values between forms VB.net
body: <p>Apologies if this is a basic question but I'm still experimenting with VB.net and I'm trying my hand at creating an event log for my test application. <em>(Not Windows event Logs)</em> - I've focused on one event, that being the time my application is launched.</p>
  
  <p>I have two forms and I'm trying to establish a permanent "link" between <code>Form1</code> and <code>Form2</code>. This means that I can send .NET commands and variables to <code>Form2</code> and on form close/open the data remains until the main application <code>Form1</code> is closed.</p>
  
  <p>Take for example the below code I'm running with <code>Form1</code> is loaded.</p>
  
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
          Form2.RichTextBox1.Text = ("Launched @ " &amp; Now.ToShortTimeString())
  
      End Sub
  </code></pre>
  
  <p><code>Form2</code> is not loaded until a Link Label titled "Event Log" is clicked within <code>Form1</code>. I have a simple <code>Form2</code> Load command for the click event on my Link Label.</p>
  
  <pre><code>Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
  
          Form2.Show()
  
      End Sub
  </code></pre>
  
  <p><code>Form2</code> consists of one RichText box, the aim of which I will add text on events of my choosing as I build the application.</p>
  
  <p>Now when I debug my application I click my Link Label the test "Launched @ xx" appears in my RichTextBox - However when I close <code>Form2</code> and then click my LinkLabel the RichTextBox is blank.</p>
  
  <p><strong>Main Questions</strong></p>
  
  <ul>
  <li>I think this is being caused because the only time I'm generating <code>RichTextBox.Text</code> is when Form1 is loaded. This is a singular instance and closing/re-opening Form2 doesn't reload Form1 and so the command <code>Form2.RichTextBox1.Text = ("Launched @ " &amp; Now.ToShortTimeString())</code> isn't ran again until I re-launch the whole application.</li>
  <li>I researched a few answers like the one <a href="https://stackoverflow.com/questions/10712407/simple-way-to-save-and-load-data-visual-basic">HERE</a>. But using settings/XML doesn't appear to be a wise choice, I mean the Time is a unique value, can I use settings to reflect this?</li>
  </ul>
  
  <p><strong>MAIN NOTE</strong> - I'm planning for the event log to be cleared every time the application is closed, I will write the contents of the RichTextBox to a .txt file on application close.</p>
  
  <p>Thanks for your advice, I would appreciate some documentation or code examples on saving strings/variables and using them between forms.</p>