Results 1 to 7 of 7

Thread: edit text file

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    edit text file

    OK, so I don't have my MSDN disks and I can't find it on the net, and the search on here doesn't seem to want to work.

    And this should be simple

    How do I open a file, replace all double quotes (ie. ") with nothing (ie. ""), and then save that file?

    I feel retarded even asking this because it seems like something that should be simple.

  2. #2
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    Did not test this, but I'm pretty sure it works
    VB Code:
    1. Dim Path as string, f as integer, temp as string
    2. Path = "C:\Target.txt"
    3. f = freefile
    4. Open path For Binary As #f
    5. temp = Space(LOF(f))    'Create a buffer for the file
    6. Get #f,,temp                'Load the textfile into the buffer
    7. temp = Replace(temp," ","")     'replace the space by nothing
    8. Close #f                                    'close the file and kill it.
    9. Kill path                                     'This because the previous data is longer then this data
    10. Open path For Binary as #f
    11. Put #f,,temp                'Write the data into the file and close it once again
    12. Close #f
    Last edited by Xa0z; Jun 19th, 2002 at 07:55 AM.
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    that didn't seem to work... i think the problem is that that code replaces spaces... and i need to replace quotes around words. is there an escape character?

    it doesn't like it when i do this:

    VB Code:
    1. temp = Replace(temp, """, "")   'replace the space by nothing

    It wants to put another quotation mark somewhere

  4. #4
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  5. #5
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    Ow sorry, I didn't read your post right :P. Thought you wanted to replace space chars. In that case use:

    temp = Replace (temp, chr(34),"")
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  6. #6

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    ahh... perfect

  7. #7
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Re: edit text file

    I have a similar problem. I have a vb script that automatically sends an email to a predetermined email address over remote smtp. I have one that uses authorazation and one that doesn't. I would like a way to have user input be populated into several fields in this script. Just something as simple as "What is your email address?" and it enters the user input into the proper line of the script. There are about 6-7 strings I want to modify this way. I'm sure if I can get one done, I can modify it for each line. Any help is greatly appreciated.

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