Reputation: 1
I'm creating a small text-based game in VB.NET and want to have a constant line of text across the top of the screen. I want any new text that appears, such as when you progress further through the game to appear below the status bar and not remove it from view.
For example
I = Inventory M = Menu E = Exit
Something to do with the game
Something else to do with the game
When you progress, I want to status bar to remain at the top of the screen
Example
I = Inventory M = Menu E = Exit
Something else to do with the game
Something further to do with the game
Any advice on how I could acheive this?
Thanks
Upvotes: 0
Views: 130
Reputation: 6206
Have your menu in one string and your scrollable data in another then when writing to the screen concatenate them.
Example:
MenuString = "I = Inventory M = Menu E = Exit"
GameString = "Something to do with the game"
GameString = GameString & vblf & "Something else to do with the game"
GameString = GameString & vblf & "Something further to do with the game"
TextBox1.Text = MenuString & vblf & GameString
Upvotes: 0
Reputation: 54532
If you look closely at the Console Class there is a CursorTop
Property which can be used to set the line that you are writing to. The top line will be 0, just avoid writing to that line if you are not wanting to change it. Here is a quick and dirty example of what I am talking about
Module Module1
Sub Main()
Dim x As Integer
Console.CursorTop = 0
Console.WriteLine("I = Inventory M = Menu E = Exit")
For x = 1 To 100
WriteDataToConsole("Action #" + x.ToString(), x)
Next
Console.ReadLine()
End Sub
Sub WriteDataToConsole(text As String, pos As Integer)
Dim temp As Integer
If pos > 20 Then
temp = (pos Mod 21) + 1
Console.CursorTop = temp
Else
Console.CursorTop = pos
End If
Console.WriteLine(text)
End Sub
End Module
Upvotes: 1