Results 1 to 3 of 3

Thread: Write to *.txt

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Belgium
    Posts
    98

    Post

    Hi,

    In this function I can write a string in a *.TXT file.
    But the text appears always on top of the file. So when I write for the 2nd time, I automaticly overwrite the previous written string with the new string.
    How can I write the next string to the next empty line of my *.TXT file?

    Thanks


    THE CODE:

    Call WriteFile("c:\MyWriteFile\Test.txt", Now())

    Function WriteFile(FileName as string, Contents as string)

    Dim i as Integer
    i = FreeFile

    Open FileName for Output as #i

    print #i, Contents
    Close #i

    End Function

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Posts
    82

    Post

    you need to open the file in append mode:

    Open FileName for append as i

    opening in append mode will add to your file while output mode will basically recreate your file each time by writing over all your data



  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Belgium
    Posts
    98

    Post Thanks

    Thanks _bman_

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