Append to a text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • awais1989
    New Member
    • Jun 2007
    • 13

    Append to a text file

    I'm using this code for writing "hi" in a file

    [CODE=vb]Private Sub Command1_Click( )
    Open "c:\temp.tx t" For Output As #1
    Print #1, "hi"
    Close #1
    End Sub[/CODE]

    but I want that whenever I press command1 it writes "hi" there without overwriting the file.
    Last edited by Killer42; Aug 20 '07, 03:13 AM. Reason: Added CODE=vb tag
  • awais1989
    New Member
    • Jun 2007
    • 13

    #2
    isn't here any1??????????? ??????????????? ??????????????? ?????

    Comment

    • kinnu
      New Member
      • Nov 2006
      • 30

      #3
      What you want to do ??? can u be clear in question?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Two points...
        • Open for Append rather than Output.
        • Don't be impatient. The information on this site is provided by volunteers, who put in their own time when they can spare it. Plus, we live all around the world, in different timezones. So you can't always expect a quick response.

        Comment

        • sivasujithsp
          New Member
          • Jun 2007
          • 4

          #5
          Another way!!!

          In menu -> Project -> References -> Microsoft Scripting Runtime

          Code:
          Dim fso As New FileSystemObject
          Dim InStream As TextStream
          
          Private Sub Command1_Click()
              
              InStream.Write ("hi")
          End Sub
          
          Private Sub Form_Load()
          Set InStream = fso.OpenTextFile("<filename_path>", ForAppending, True)
          End Sub

          Comment

          Working...