Console App - Visually Showing Activity

I would like to show activity within a console app by using a spinning cursor using a combination of pipe, forward slash, back slash and minus sign. How do I print to the same line and overwrite the last character that has been printed on a terminal window?

On Windows I blank the line then without the .

If you place this code

[code] Dim states() As String = Split("/-\|", “”)
Dim i As Integer

Do
stdout.Write " " + chr(&h0D) + states(i)
i = i + 1
If i > states.Ubound Then i = 0
DoEvents(50)
Loop[/code]

In the run event of a console app you’ll see a nice console spinning wheel. Not tested on OSX or Linux though.

Of course you can also spin the wheel at the end of the line with

[code] Dim states() As String = Split("/-\|", “”)
Dim i As Integer

stdout.Write "A spinning wheel "
Do
stdout.Write Chr(&h08) + states(i)
i = i + 1
If i > states.Ubound Then i = 0
DoEvents(50)
Loop[/code]

Where I use a backspace to remove the previous char. Again not tested in other OS’s.

Works on OS X. Quite nice :slight_smile:

Thanks Wayne. Spot on, just what I was after and yes works fine on OS X