Console line

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
Ffenixw0rks
VIP - Donator
VIP - Donator
Posts: 152
Joined: Sun Jun 19, 2011 2:51 pm

Console line
Ffenixw0rks
Can I bind first line of console to specific text and change it in future?

Like in Counter Strike 1.6 console server - first line will display only server stats, whyle other lines working as console lines( :lol: )

Like this:
Image
First line is my goal.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Console line
mandai
You can get the current console cursor position with Console.CursorLeft and Console.CursorTop.

You can use this to move the cursor to the top left:
Code: Select all
Console.SetCursorPosition(0, 0)
When you have finished writing to the top line you can also put the cursor back to where it was.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Console line
MrAksel
So the whole code would be:
Code: Select all
Private Sub WriteSomethingInRedAtTheTop(ByVal s As String)
   Dim cursorLeft As Integer = Console.CursorLeft
   Dim cursorTop As Integer = Console.CursorTop
   Dim color As ConsoleColor = Console.ForegroundColor

   Console.SetCursorPosition(0, 0)

   Console.ForegroundColor = ConsoleColor.Red
   Console.Write(s)

   Console.ForegroundColor = color
   Console.SetCursorPoistion(cursorLeft, cursorTop)
End Sub
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
3 posts Page 1 of 1
Return to “Coding Help & Support”