Results 1 to 5 of 5

Thread: Text File. Please Help!

  1. #1

    Thread Starter
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535

    Arrow

    I am using the following code to add a string of text to a file which already contains some data. But when I enter any string to the file, the old data gets erased out and only the new string is left.

    The code:

    Private Sub cmdAdd_Click()
    dim strAdd as string
    strAdd = Text1 & Text2
    open App.Path & "\Test.txt" for Output as #1
    Print #1, strAdd
    close #1
    End Sub

    How do I modify my code to write the new string after the end of existing data in the file.


    Thanks

    Kinjal

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    here you go:

    Code:
    Private Sub cmdAdd_Click() 
    dim strAdd as string 
    strAdd = Text1 & Text2 
    open App.Path & "\Test.txt" for Append as #1 
    Append #1, strAdd 
    close #1 
    End Sub
    NXSupport - Your one-stop source for computer help

  3. #3
    Guest
    Wrong way dimava.

    Code:
    Private Sub cmdAdd_Click() 
    dim strAdd as string 
    strAdd = Text1.text & Text2.text
    open App.Path & "\Test.txt" for Append As #1 
    Print #1, strAdd 
    Close #1 
    End Sub

  4. #4
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    for some reason, today I've been making those little mistakes all day.
    NXSupport - Your one-stop source for computer help

  5. #5

    Thread Starter
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    Thanks a lot both of you. It really solved my problem.


    Thnaks a lot once again.

    Kinjal

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