title: Passing String to another sub routine
body: <p>I am trying to practice embedding my code. I created a subroutine called <code>JrnlHeader</code> to declare variables I will use in another subroutine.  I am currently only concerned with one variable named <code>Header</code>.  I would like to know why <code>Header</code> is empty in subroutine <code>PrintToTextFile</code> and how I can fix it to be able to use strings declared in JrnlHeader.</p>
  
  <pre><code>Private Sub JrnlHeader()
      Dim Header As String
      Dim SeqNo As String
      Dim SeqVar As String
      Dim Bu As String
      Dim BuVar As String
      Dim JrnlID As String
      Dim JrnlIDVar As String
      Dim JrnlDate As String
      Dim JrnlDateVar As String
      Dim Descr As String
      Dim DescrVar As String
      Dim Ledger As String
      Dim LedgerVar As String
      Dim Source As String
      Dim SourceVar As String
      Dim CurEff As String
      Dim Reverse As String
      Dim AutoLn As String
      Dim AdjEnt As String
  
      Header = "&lt;JRNL_HDR_IMP&gt;"
      SeqNo = "&lt;SEQNO&gt;" &amp; SeqVar &amp; "&lt;/SEQNO&gt;"
      Bu = "&lt;BUSINESS_UNIT&gt;" &amp; BuVar &amp; "&lt;/BUSINESS_UNIT&gt;"
      JrnlID = "&lt;JOURNAL_ID&gt;" &amp; JrnlIDVar &amp; "&lt;/JOURNAL_ID&gt;"
      JrnlDate = "&lt;JOURNAL_DATE&gt;" &amp; JrnlDateVar &amp; "&lt;/JOURNAL_DATE&gt;"
      Descr = "&lt;DESCR254&gt;" &amp; DescrVar &amp; "&lt;/DESCR254&gt;"
      Ledger = "&lt;LEDGER_GROUP&gt;" &amp; LedgerVar &amp; "&lt;/LEDGER_GROUP&gt;"
      Source = "&lt;SOURCE&gt;" &amp; SourceVar &amp; "&lt;/SOURCE&gt;"
      CurEff = "&lt;CUR_EFFDT&gt;" &amp; JrnlDateVar &amp; "&lt;/CUR_EFFDT&gt;"
      Reverse = "&lt;REVERSAL_CD&gt;N&lt;/REVERSAL_CD&gt;"
      AutoLn = "&lt;AUTO_GEN_LINES&gt;N&lt;/AUTO_GEN_LINES&gt;"
      AdjEnt = "&lt;ADJUSTING_ENTRY&gt;N&lt;/ADJUSTING_ENTRY&gt;"
  End Sub
  
  Sub PrintToTextFile()
      Dim FileNum As Integer
  
      JrnlHeader
  
      FileNum = FreeFile ' next free filenumber
  
      'Open "C:\Temp\TEXTFILE.TXT" For Output As #FileNum ' creates the new file
      Open "C:\temp\TEXTFILE.TXT" For Append As #FileNum
      Print #FileNum, Header
      Close #FileNum ' close the file
  End Sub
  </code></pre>