Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

VB.NET Console | Update variable w/o clearing screen?

I'm working on a project that detects matches in a text file. If a match is found, it displays an asterisks in the terminal. However...when a second or more match(s) are found, instead of displaying another asterisks on a second line I want to add it to the same line.

What I have so far is this:
Code
    For Each fileLn As String In File.ReadLines("C:\path\file.txt")
        If fileLn.ToString = "0x0" Then
              Add()
        End If
    Next

Private Sub Add()
    'Add another asterisks to same line.
End Sub()

...and what I plan to have it look like is this:
[Image: HblMF0I.png]

In a sense I could just add an asterisks to an already existing variable and just clear/re-echo everything, but that causes lag, etc. I was wondering if anyone knew how to update the line rather than displaying everything over again?
(Dec 21, 2020 04:14 PM)mutate Wrote:  I'm working on a project that detects matches in a text file. If a match is found, it displays an asterisks in the terminal. However...when a second or more match(s) are found, instead of displaying another asterisks on a second line I want to add it to the same line.

What I have so far is this:
Code
    For Each fileLn As String In File.ReadLines("C:\path\file.txt")
        If fileLn.ToString = "0x0" Then
              Add()
        End If
    Next

Private Sub Add()
    'Add another asterisks to same line.
End Sub()

...and what I plan to have it look like is this:
[Image: HblMF0I.png]

In a sense I could just add an asterisks to an already existing variable and just clear/re-echo everything, but that causes lag, etc. I was wondering if anyone knew how to update the line rather than displaying everything over again?

Think you are looking for Console.Write instead of Console.WriteLine :)
(Dec 21, 2020 04:22 PM)Prawnster Wrote:  Think you are looking for Console.Write instead of Console.WriteLine :)

How so?

I'm sorta new to VB Console. I've used Console.Write when setting user inputs as variables. How should I implement that?
(Dec 21, 2020 04:32 PM)mutate Wrote:  How so?

I'm sorta new to VB Console. I've used Console.Write when setting user inputs as variables. How should I implement that?

What he means is that Console.Writeline will display text on that 1 line and move on to the next line, so you should use Console.Write instead of console.writeline.
Something like this:

Code
For Each fileLn As String In File.ReadLines("C:\path\file.txt")
        If fileLn.ToString = "0x0" Then
              Add()
        End If
    Next

Private Sub Add()
    'Add another asterisks to same line.
    Console.Write("*")
End Sub()
(Dec 21, 2020 04:32 PM)mutate Wrote:  How so?

I'm sorta new to VB Console. I've used Console.Write when setting user inputs as variables. How should I implement that?
(Dec 21, 2020 04:46 PM)Ajumma Wrote:  What he means is that Console.Writeline will display text on that 1 line and move on to the next line, so you should use Console.Write instead of console.writeline.
Something like this:

Code
For Each fileLn As String In File.ReadLines("C:\path\file.txt")
        If fileLn.ToString = "0x0" Then
              Add()
        End If
    Next

Private Sub Add()
    'Add another asterisks to same line.
    Console.Write("*")
End Sub()

Yeah that's what I mean haha, thanks for explaining sorry, lmk if it works op :)
(Dec 21, 2020 04:46 PM)Ajumma Wrote:  What he means is that Console.Writeline will display text on that 1 line and move on to the next line, so you should use Console.Write instead of console.writeline.
Something like this:

(Dec 21, 2020 05:09 PM)Prawnster Wrote:  Yeah that's what I mean haha, thanks for explaining sorry, lmk if it works op :)

You suggestions worked gentlemen, thanks! For some reason I didn't comprehend that fix 😵


Possibly Related Threads...
Thread / Author Replies Views Last Post
[The Brotherhood] by HackersApr 10, 2026 02:15 AM 22 2,146 Apr 10, 2026 02:15 AM
Last Post: PELock
[C#] by gigajewMar 28, 2018 03:38 PM 3 372 Mar 28, 2018 03:38 PM
Last Post: Ninja
[C#] by zetzaSep 19, 2017 04:14 AM 8 267 Sep 19, 2017 04:14 AM
Last Post: zetza