title: Making public after being Private - Visual Basic
body: <p>Currently in the process of &quot;self teaching&quot; visual basic so apologies for the basic question</p>
  <p>Maybe I am going about this the wrong way but I want to use <code>btnTA_StartLog</code> to create a file and activate <code>Timer1</code> to log data in a specified interval.  Problem being <code>outlog</code> is only defined in <code>btnTA_startLog</code> and not in the other 2 subs. How can I make the recently declared <code>outlog</code> public and accessible to the other subs?</p>
  <pre class="lang-vb prettyprint-override"><code>Public Sub btnTA_StartLog_Click(sender As Object, e As EventArgs) Handles btnTA_StartLog.Click
      Dim file As String = GetFileName(False, &quot;csv&quot;, &quot;Data Output&quot;)
      Dim outlog As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(file, True)
      Timer1.Start()
      btnTA_StartLog.Enabled = False
      btbTA_LoggingStop.Enabled = True
  End Sub
  
  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
      outlog.WriteLine(CStr(DateTime.Now) &amp; &quot;,&quot; &amp; CStr(txbTA_Delivered_ml.Text) &amp; &quot;,&quot; &amp; CStr(MyTC.Data.Temperature))
  End Sub
  
  Private Sub btbTA_LoggingStop_Click(sender As Object, e As EventArgs) Handles btbTA_LoggingStop.Click
      Timer1.Stop()
      outlog.Close()
  End Sub
  </code></pre>