By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,032 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,032 IT Pros & Developers. It's quick & easy.

console.write

P: n/a
vb.net 2003 - console program

i've read a array of machines and i wishes to display on console the
machines name on the *same line.* How do i do this ? This is what i want

say i got a text file that contains
machine001
machine002

it shld display in console as

computer : machine001 (machine 001 will disappear, then machine002 will
appear on the same line and on the same location/placeholder)

eg

dim computer as string

for each computer in machinesarray
console.write(computer)
next
Feb 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Using Console.Write(computer) on it's own means that that subsequent calls
will write at the next position giving:

computer : machine001machine002... etc.

If I understand you correctly what you want to see is:

computer : machine001

and then

computer : machine002

in place of what was written previously, thus giving the effect of the
machine name counting up.

To achieve this you need to force the next position back to the beginning of
the line by writing a carriage return:

Console.Write("computer : " & computer & ControlChars.Cr)

Now, in a tight loop like:

For Each computer In machinesarray
Console.Write(computer & ControlChars.Cr)
Next

it is all going to happen so fast that you are only ever going to see the
final entry.

You need to add as timing delay so that you can see it happening:

For Each computer In machinesarray
Console.Write(computer & ControlChars.Cr)
Thread.Sleep(1000) ' Wait for 1 second
Next

Adjust the parameter of the Sleep method to control the delay between
iterations of the loop.
"James" <jk****@hotmail.com> wrote in message
news:uQ****************@TK2MSFTNGP10.phx.gbl...
vb.net 2003 - console program

i've read a array of machines and i wishes to display on console the
machines name on the *same line.* How do i do this ? This is what i want

say i got a text file that contains
machine001
machine002

it shld display in console as

computer : machine001 (machine 001 will disappear, then machine002 will
appear on the same line and on the same location/placeholder)

eg

dim computer as string

for each computer in machinesarray
console.write(computer)
next

Feb 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.