Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating current line in VB Console

I am trying to write out to console a percentage of data loading. I tried to use C# syntax which would be Console.Write("\rPercentage: " + nCurrent + "/" + nTotal; however in VB I get the actual character 'r' being displayed in my string. Is there a special code I need to insert in order to update my cursor to the beginning of the line so that I may reuse that line?

Thanks

like image 467
Seb Avatar asked Oct 13 '11 18:10

Seb


People also ask

How do you overwrite a line in console?

How to overwrite an existing line without terminal sequence. The \r or carriage return will put the cursor at the beginning of the line and allows you to overwrite the content of the line.

What is console WriteLine ()?

WriteLine(Object) Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream. WriteLine(String, Object, Object, Object, Object)

What is WriteLine in VB net?

WriteLine() method displays the output and also provides a new line character it the end of the string, This would set a new line for the next output.


1 Answers

Use vbCr to generate a carriage return character:

        Console.Write("{0}Percentage: {1}/{2}", vbCr, nCurrent, nTotal)
like image 120
Hans Passant Avatar answered Oct 08 '22 14:10

Hans Passant