Hack Forums
[.NET] VB.NET Console | Update variable w/o clearing screen? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] VB.NET Console | Update variable w/o clearing screen? (/showthread.php?tid=6128773)



VB.NET Console | Update variable w/o clearing screen? - mutate - Dec 21, 2020

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?


RE: VB.NET Console | Update variable w/o clearing screen? - Prawnster - Dec 21, 2020

(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 :)


RE: VB.NET Console | Update variable w/o clearing screen? - mutate - Dec 21, 2020

(Dec 21, 2020 04:22 PM)Mazl 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?


RE: VB.NET Console | Update variable w/o clearing screen? - Ajumma - Dec 21, 2020

(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()



RE: VB.NET Console | Update variable w/o clearing screen? - Prawnster - Dec 21, 2020

(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 :)


RE: VB.NET Console | Update variable w/o clearing screen? - mutate - Dec 22, 2020

(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)Mazl 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 😵