Results 1 to 6 of 6

Thread: [RESOLVED] delete a files contents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Location
    Belfast
    Posts
    116

    Resolved [RESOLVED] delete a files contents

    Hi all, im trying to delete the contents of a file and then just copy in a label name, but im not sure how to do it, is this possible?

    Or would it just be easier to "kill" the file then recreate a new identical filename and put in what i want then?

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: delete a files contents

    The easiest way would be to Kill the original file and create a new one with the new contents.....HTH

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: delete a files contents

    How are you writing to the file? I don't think you will need to delete the contents of the file if you use OutPut As # statement. Everytime the file will be overwritten.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Location
    Belfast
    Posts
    116

    Re: delete a files contents

    i am using "print #1, label5.caption" but i think ill go along with the kill statement, probably my best bet, thanks guys

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: delete a files contents

    Quote Originally Posted by paulhenderson
    i am using "print #1, label5.caption" but i think ill go along with the kill statement, probably my best bet, thanks guys
    Why would you write extra lines of code when it can be done with a single statement. Just use
    VB Code:
    1. Open "C:\Testfile.txt" For OutPut As #1
    2. Print #1, Label5.Caption
    3. Close #1
    This will make sure that the contents of the file are overwritten everytime you write to the file. No need to delete the file.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Location
    Belfast
    Posts
    116

    Re: [RESOLVED] delete a files contents

    thanks Shuja Ali, appreciate it!!!!

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