iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Edit Text in VBS

104 7
    • 1). Open your favorite text editor.

    • 2). Paste the following:

      dim FSO, textFile

      const ForWriting = 2

      const ForAppending = 8

      set FSO = CreateObject("Scripting.FileSystemObject")

      set textFile = FSO.OpenTextFile("c:\textfile.txt", ForWriting)

      textFile.WriteLine "This will overwrite all the current contents of the file and replace it with this sentence."

      textFile.Close

      set textFile = FSO.OpenTextFile("c:\textfile.txt", ForAppending)

      textFile.WriteLine "This will be appended to the end of the file!"

      textFile.Close

      This declares two constants for two different file input/output modes: ForWriting and ForAppending. If a file is opened with the "ForWriting" flag, then new text will wipe all the current contents of the file. On the other hand, if the "ForAppending" flag is used, the new text will be added to the end of the current file, preserving all its contents.

    • 3). Save your work. You can run the script by double-clicking it.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.