Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know that this issue is mostly aesthetic, but stuff like this annoys me. I hate to answer my own question, but I actually came up with a pretty decent solution for this based on some input from others. I will attach a code sample in case anyone wants to do something similar in the future. I know there are probably better ways to do this, but here's what I did.</p> <p>Basically instead of using console.writeline from each thread, I created a new sub routine (TextOut) which has some logic behind it. I also updated my input thread to read each char into a shared string instead of using console.readline(). Here is the code:</p> <pre class="lang-vb prettyprint-override"><code>Private command As String = "" Private Sub ConsoleInput() Dim cki As ConsoleKeyInfo cki = Console.ReadKey() If cki.Key = ConsoleKey.Escape Then command = "" 'Clear command ElseIf cki.Key = ConsoleKey.Backspace Then If Len(command) &gt; 0 Then 'Make sure you don't go out of bounds For i As Integer = 0 To Len(command) Console.Write(" ") 'Clear output since new string will be shorter Next command = Left(command, Len(command) - 1) 'Shorten command by 1 char End If Console.CursorLeft = 0 'Set the cursor to the beginning of the line Console.Write(command) 'Write the command to the screen ElseIf cki.Key = ConsoleKey.Enter Then 'Command has been submitted, start checking Console.CursorLeft = 0 'Set the cursor to the beginning of the line For i As Integer = 0 To Len(command) Console.Write(" ") 'Clear output from command (hides the executed command) Next Dim tempCMD As String = command command = "" 'If/then statements for validating command goes here command = "" 'Clear command to allow new input Else command += cki.KeyChar 'Add char to command string Console.CursorLeft = 0 'Set the cursor to the beginning of the line Console.Write(command) 'Write the command to the screen End If ConsoleInput() 'Loop for more input End Sub Sub TextOut(ByVal message As String) If command &lt;&gt; "" Then For i As Integer = 0 To Len(command) Console.Write(" ") 'Clears output in case output is shorter than current command Next Console.CursorLeft = 0 'Sets cursor to beginning of row End If Console.WriteLine(message) 'Writes the current message to the screen If message &lt;&gt; command Then Console.Write(command) 'Writes the command back to the screen End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload