Results 1 to 8 of 8

Thread: Notepad question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    140
    Hello All,

    My question is:

    Is there a way to open up the file (Notepad), and do the search for a certain word and then change it to some different word ???


    Thanks,

  2. #2
    Guest
    you can open up a text file that you would normally open in notepad and do pretty much anything you want to it.
    look into :

    OpenAsTextStream method /file system object/
    instr function
    mid function


    here is the code to open a text file and read a
    line from it.
    Code:
    Sub TextStreamTest()
        Const ForReading = 1, ForWriting = 2, ForAppending = 3
        Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
        Dim fs, f, ts, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        fs.CreateTextFile "test1.txt"            'Create a file
        Set f = fs.GetFile("test1.txt")
        Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
        ts.Write "Hello World"
        ts.Close
        Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
        s = ts.ReadLine
        MsgBox s
        ts.Close
    End Sub
    now just figure out how you want to parse the line and replace the data.


  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    BG!

    What is the difference with your method and the regular Open File Output as #1
    Chemically Formulated As:
    Dr. Nitro

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    140
    Hi BG,

    The part of parse the line and replace the data is where I dont know what to do.

    Example: I have the following data

    [inetinfo]
    Disable=1
    [services]

    I'd like to replace

    "Disable=1" TO "Disable=0"

    Thank you in advance

  5. #5
    Guest
    nitro,
    This way uses the file system object(scrrun.dll)
    It has a lot of file system methods, like, Returning file attributes, editing txt files, directory and file commands. it's pretty easy to use and saves a lot of time coding.

    lieu,
    hold on let me find the code for ya




  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Thanks for the clarification buddy!

    Have a nice day!
    Chemically Formulated As:
    Dr. Nitro

  7. #7
    Guest
    looks like you should be using a .ini file, check this link out, the code is there already.
    http://visualbasic.about.com/compute...y/aa121998.htm

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    140
    Thank You very much BG for your information. It works beautifully

    Thanks again

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