Thread: Clear console trace

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    4

    Unhappy Clear console trace

    Hello all,

    I'm very new in C# and need your help.

    I have a 3 values to print in the console screen with the following position.

    A
    F
    B

    With cursor position I can get this result, but when I’m starting to move A and B to F and it is OK (at least it seems to be), but I want to remove the A’s and B’s trace.
    Currently it works like

    AAAAAAA
    F
    BBBBBBB

    But I want to be like the example below:
    each time the A’s and B’s position changes the previews char remove like
    A
    F
    B

    A
    F
    B
    and until F.

    Could you help me please?
    Below is the code I have.

    Code:
                char chA = 'R';
                char chB = 'B';
    
                string fin = "F";
    
                int posA = 0;
                int posB = 0;
    
                int finish = 100;
                //Print once only and keep the text
                Console.SetCursorPosition(finish, 1);
                Console.WriteLine(fin);
    
                while (finish != 1)
               {
                    Console.SetCursorPosition(posA, 0);
                    Console.WriteLine(chA);
                  
                    if (finish  ==10)
                    {
                        posA += 2;
                    }else
                    {
                        posA += 1;
                    }
                    
                    Console.SetCursorPosition(posB, 2);
                    Console.WriteLine(chB);
                    posB = posB + 1;
                   
                    Thread.Sleep(300);
                    
                    --finish;
        }
    Thanks in advance

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    4
    Quote Originally Posted by Arsench View Post
    Hello all,

    I'm very new in C# and need your help.

    I have a 3 values to print in the console screen with the following position.

    A
    F
    B

    With cursor position I can get this result, but when I’m starting to move A and B to F and it is OK (at least it seems to be), but I want to remove the A’s and B’s trace.
    Currently it works like

    AAAAAAA
    F
    BBBBBBB

    But I want to be like the example below:
    each time the A’s and B’s position changes the previews char remove like
    A
    F
    B

    A
    F
    B
    and until F.

    Could you help me please?
    Below is the code I have.

    Code:
                char chA = 'R';
                char chB = 'B';
    
                string fin = "F";
    
                int posA = 0;
                int posB = 0;
    
                int finish = 100;
                //Print once only and keep the text
                Console.SetCursorPosition(finish, 1);
                Console.WriteLine(fin);
    
                while (finish != 1)
               {
                    Console.SetCursorPosition(posA, 0);
                    Console.WriteLine(chA);
                  
                    if (finish  ==10)
                    {
                        posA += 2;
                    }else
                    {
                        posA += 1;
                    }
                    
                    Console.SetCursorPosition(posB, 2);
                    Console.WriteLine(chB);
                    posB = posB + 1;
                   
                    Thread.Sleep(300);
                    
                    --finish;
        }
    Thanks in advance
    Well I have resolved it replacing with char = '\n'; with previews position.
    Like this:

    Code:
    Console.SetCursorPosition(posB - 1, 2); Console.WriteLine(chB.ToString().Replace(chB, '\n'));
    if someone needs to use it.

    Regards

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Clear Console Screen
    By Cero.Uno in forum C Programming
    Replies: 3
    Last Post: 04-21-2008, 03:45 PM
  2. Clear Screen in C++ console
    By ay_okay in forum C++ Programming
    Replies: 9
    Last Post: 12-21-2004, 04:05 AM
  3. Standard way to clear the console (?)
    By Perspective in forum C++ Programming
    Replies: 22
    Last Post: 09-12-2004, 12:33 PM
  4. Clear the Console Screen
    By Gnoober in forum C++ Programming
    Replies: 4
    Last Post: 10-15-2002, 05:28 PM
  5. clear the screen in console input
    By enggas in forum Linux Programming
    Replies: 4
    Last Post: 07-23-2002, 12:06 PM

Tags for this Thread