title: VBA Excel User Form Output to Txt File
body: <p>I am trying to create a user form that takes user input and prints to a text file. I know the VBA scripting functions to print, store strings etc. BUT I'm new to userforms. How do you limit input and output to a text file? Add to that same file?</p>
  
  <p>INPUT AND OUTPUT:</p>
  
  <p><img src="https://i.stack.imgur.com/sTTOT.png" alt="inputandoutput"></p>
  
  <p>I would need to have this variety of</p>
  
  <p><strong>KEY FEATURES:</strong></p>
  
  <ol>
  <li><p><strong>Limited Entry:</strong> XXXX means only enter 4 characters (The notepad file can only be certain characters long</p></li>
  <li><p><strong>Multiple Entries:</strong> After a set of records is entered to the text file, their values are stored and another input is allowed. Also the new entries have to be written to the same file on the next line</p></li>
  <li><p><strong>Space if left blank:</strong> If XXXX is left blank then four " " should be printed instead.</p></li>
  </ol>
  
  <p>If you have part or all of these answers I'd like to hear from you! </p>
  
  <p>---------------------------Edited with Adding Code-----------------------------</p>
  
  <pre><code>Private Sub Userform_Initialize()
  
  'Fill Eggs
  With Eggs
      .AddItem "Eggs"
  End With
  
  End Sub
  
  Private Sub CreateList_Click()
  
  Dim myFile As String, myString As String
  myFile = "C:\Reformatted.txt"
  Open myFile For Output As #1
  
  Dim fourChars As String * 4
  fourChars = Milk.Value
  
  myString = Eggs.Value + Milk.Value + Bread.Value
  
  Print #1, myString
  
  Close #1
  Shell "C:\Windows\Notepad.exe C:\Reformatted.txt", 1
  
  End Sub
  </code></pre>
  
  <p>So the above code launches this screen:</p>