How to update a value in Console Application

aliweb

Active member
Joined
Sep 14, 2005
Messages
40
Programming Experience
3-5
Hi

I am making a command line program in VB.Net that goes throught a loop and displays progress on screen like the following:

Done...1%

Now this 1% will increase as the loop progresses.

Problem is to write on command line we have two functions
Write and WriteLine and both writes a new character on the screen so if I use anyone of them my output will become something like this.

Write
------
Done 1% 2% 3% 4%

WriteLine
---------
Done 1%
2%
3%
4%

But what I want it should update the percentage value and not print new value.
This can be very easily achieved in a GUI program whereby I can put a label on a form and keep updating its value but how can I do it in a command line program?
 
Thanks man!
I think the function in that class you are talking about is "Move the text cursor location" using which I can move the cursor to a specified position and write something! isn't it!?
 
Hi Ali,
Take a look at this MSDN article http://support.microsoft.com/default.aspx?scid=kb;en-us;319239
If it looks confusing to you here is one practical example how to use it ... just instantiate the class and add it before console write new line

HTH
Regards ;)

this will show the percentage from 1-100 just in same line
 

Attachments

  • Percentage.zip
    15.4 KB · Views: 96
Yes this is what I am doing at present. Clearing the screen everytime and then writing all the text again. But thankx any way :)
 
.Net 2.0 does have the required Console.SetCursorPosition Method.
Just thought this was worth mentioning.
 
Back
Top