wscript.stdOut: overwrite previous line RRS feed

  • Question

  • All

    I do know this forum is for VBA, but I don't find one for VBS so I hope someone can help me.

    I once had a VBS-script (unfortunately lost it) where I could overwrite text on last output line

    Code below outputs 100 sentences and each sentence is on a new line. The VBS-code I had only used one line. It did not attach the new sentence at the end, but overwrote the existing text. So in this example, it looked as only the first line was written (Step 1 of 100) and from then only the number X was updated on that same line.

    Dim x, y
    Dim objStdOut
    y = 100
    Set objStdOut = WScript.StdOut
    For x = 1To y
        objStdOut.Writeline"Step " & x & " of " & y
        'some code to jump back to previous line to have it overwritten by next text

    Does someone know how this can be done?


    • Edited by kvhoof Thursday, June 2, 2016 1:19 PM
    Thursday, June 2, 2016 1:14 PM

All replies

  • It sounds like you need to open the file using random.  Here is an article on how it works.  I have used it to edit a large text file but generally it is easier to read a file, modify the lines and then write a new file.
    Thursday, June 2, 2016 1:46 PM