Results 1 to 3 of 3

Thread: Adding text to notepad file

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    4

    Adding text to notepad file

    Is there a way to add text into a notepad file without deleting what was already in the notepad file?
    Right not im using this to add text to a notepad file.
    Code:
       Dim hFile As Long
       Dim sFilename As String
    
       sFilename = "c:\demo.txt"
       
    
       hFile = FreeFile
       Open sFilename For Output As #hFile
          Print #hFile, Text1.Text
       Close #hFile
    The problem is that it overwrites the text already in the notepad file.
    I cant store the text from the notepad file in a temporary textbox because theres too many characters in the notepad file and a textbox cannot fit it all.

  2. #2
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Adding text to notepad file

    Code:
    Open sFilename For Append As #hFile
          Print #hFile, Text1.Text
    Close #hFile

  3. #3
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: Adding text to notepad file

    FireXtol is exacly right. Instead of using Output, you use Append. This will just add text to the end of the notepad document.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width