Results 1 to 4 of 4

Thread: editing a .cfg file or text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    4

    editing a .cfg file or text file

    Hello,
    i need to know what code to use for editing certain parts of a .cfg or .txt file.
    I want it to find a certain string and replace it.
    Thankyou

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: editing a .cfg file or text file

    do a search in the forum, or look in the codebank
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: editing a .cfg file or text file

    Read the file into a textbox, make your changes, and save it back out overlaying the original.

  4. #4
    Lively Member
    Join Date
    Feb 2007
    Posts
    65

    Re: editing a .cfg file or text file

    Here Is Something That I Made Hope Its Usefull

    Code:
    Private Sub btnLoad_Click()
    FF = FreeFile
    Open "C:\Test.txt" For Input As #FF ' Or You Can Try "C:\Test.cfg" Or Choose Other Path
    Input #FF, TextOfFile
    txtFile.Text = TextOfFile
    Close #FF
    End Sub
    
    Private Sub btnSave_Click()
    FF = FreeFile
    Open "C:\Test.txt" For Output As #FF ' Or You Can Try "C:\Test.cfg" Or Choose Other Path
    Print #FF, txtFile.Text
    Close #FF
    End Sub

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