Clear Screen with the Cls Method


Written By TheVBProgramer.



Similar to the DOS command that clears the console screen, the Cls method clears all text that was output directly to the form. This is a method that you will rarely use in regular VB applications, although it will suit our purposes for the "Try It" sample programs.


As you saw from the initial "Try It" example, to clear text that was directly written to the form, all you need to do is code the keyword Cls on a line by itself.


You could have optionally coded formname.Cls, as in:






(The keyword Me refers to the form in which code is currently running.)


Note: The Cls method can also be used with the PictureBox control.

If you enjoyed this post, subscribe for updates (it's free)

Cls while a Console.ReadLine is active,

I wrote an application that needs to refresh every X seconds,
while the command prompt is active.

Console.Readline appears to wait for an input,
I was thinking of linking to applications, One for the input,(just a command prompt) and one for the output

and the other to display the data,

How do I set up a data stream from one application to another?

Module MainModule
''Define DataSets

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public TimeNews As Double
Dim strInput As String

Private M As Integer

Private dsNames As New DataSet
Private dvNames As DataView

Public indexData As Integer

Private promptMessage As String = "Enter employee number to see information"
Private welcomeMessage As String = "Employee Information and Schedule application"

Sub Main()


' Populates the dataset, dsNames, with the Names table
' and create a sorted view of the Names table on the Employee ID field.


strInput = UCase(Console.ReadLine())
Dim TimeNews As Double = 0


While strInput <> "QUIT"

' Check to ensure that a number was entered as Employee ID.
While Not (IsNumeric(strInput) Or UCase(strInput) = "QUIT" Or UCase(strInput) = "Edit")
Console.WriteLine("A Numeric Employee ID is required.")
Console.WriteLine("Please reenter the Employee ID or QUIT to continue.")
Dim TimeAlpha As Integer
TimeAlpha = 0
'' Waits 10X50 Milliseconds
Do While TimeAlpha < 100
TimeAlpha = TimeAlpha + 1

If TimeAlpha = 50 Then
strInput = Console.ReadLine()
If TimeAlpha < 50 Then
GoTo Alpha
End If
End If


End While

' Exit on "quit".

If UCase(strInput) = "Edit" Then
Console.WriteLine("Input Employee Number ")
Console.WriteLine("Input a employee to edit")
Dim InputA As String = Console.ReadLine()

End If

If UCase(strInput) = "QUIT" Then
End If

' Display the product information if a valid product id was found.
' If the product id was not found, display an exception message.
indexData = dvNames.Find(strInput)
If indexData = -1 Then
Console.WriteLine("No employee with That Id found.")

Console.Write("Employee Name: ")
Console.Write("Hours Allowed Per Week: ")
Console.Write("Pay Rate: ")
Console.Write("Legally allowed to work in usa: ")
Console.Write("Week Beginning ")
Console.Write("Today is ")
Console.Write(" ")
Console.Write(" ")
Dim NumX As Double = (Hour(Now))
If (Hour(Now)) > 12 Then NumX = (NumX - 12)
If NumX = 0 Then NumX = (NumX + 1)

Console.Write(" and the Time is ")
Console.Write("Shifts assigned ")

Console.WriteLine("Mon,Tue,Wed,Thur,Fri,Sat,Sun ")
Console.Write("First shift { ")
Dim A As String = CStr((dvNames(indexData)("ShiftsMon")))
If A = "Cook" Then Console.Write("C ")
If A = "Front" Then Console.Write("F ")
If A = "False" Then Console.Write("0 ")
If A = "True" Then Console.Write("X ")
Dim B As String = CStr(((dvNames(indexData)("ShiftsTue"))))
If B = "Cook" Then Console.Write("C ")
If B = "Front" Then Console.Write("F ")
If B = "False" Then Console.Write("0 ")
If B = "True" Then Console.Write("X ")
Dim C As String = CStr(((dvNames(indexData)("ShiftsWed"))))
If C = "Cook" Then Console.Write("C ")
If C = "Front" Then Console.Write("F ")
If C = "False" Then Console.Write("0 ")
If C = "True" Then Console.Write("X ")
Dim D As String = CStr(((dvNames(indexData)("ShiftsThur"))))
If D = "Cook" Then Console.Write("C ")
If D = "Front" Then Console.Write("F ")
If D = "False" Then Console.Write("0 ")
If D = "True" Then Console.Write("X ")
Dim E As String = CStr(((dvNames(indexData)("ShiftsFri"))))
If D = "Cook" Then Console.Write("C ")
If D = "Front" Then Console.Write("F ")
If D = "False" Then Console.Write("0 ")
If D = "True" Then Console.Write("X ")
Dim H As String = CStr(((dvNames(indexData)("ShiftsSat"))))
If H = "Cook" Then Console.Write("C ")
If H = "Front" Then Console.Write("F ")
If H = "False" Then Console.Write("0 ")
If H = "True" Then Console.Write("X ")
Dim I As String = CStr(((dvNames(indexData)("ShiftsSun"))))
If I = "Cook" Then Console.WriteLine("C }")
If I = "Front" Then Console.WriteLine("F }")
If I = "False" Then Console.WriteLine("0 }")
If I = "True" Then Console.WriteLine("X }")
Console.Write("Second Shift { ")
Dim A1 As String = CStr(((dvNames(indexData)("ShiftsMon1"))))
If A1 = "Cook" Then Console.Write("C ")
If A1 = "Front" Then Console.Write("F ")
If A1 = "False" Then Console.Write("0 ")
If A1 = "True" Then Console.Write("X ")
Dim B1 As String = CStr(((dvNames(indexData)("ShiftsTue1"))))
If B1 = "Cook" Then Console.Write("C ")
If B1 = "Front" Then Console.Write("F ")
If B1 = "False" Then Console.Write("0 ")
If B1 = "True" Then Console.Write("X ")
Dim C1 As String = CStr(((dvNames(indexData)("ShiftsWed1"))))
If C1 = "Cook" Then Console.Write("C ")
If C1 = "Front" Then Console.Write("F ")
If C1 = "False" Then Console.Write("0 ")
If C1 = "True" Then Console.Write("X ")
Dim D1 As String = CStr(((dvNames(indexData)("ShiftsThur1"))))
If D1 = "Cook" Then Console.Write("C ")
If D1 = "Front" Then Console.Write("F ")
If D1 = "False" Then Console.Write("0 ")
If D1 = "True" Then Console.Write("X ")
Dim E1 As String = CStr(((dvNames(indexData)("ShiftsFri1"))))
If E1 = "Cook" Then Console.Write("C ")
If E1 = "Front" Then Console.Write("F ")
If E1 = "False" Then Console.Write("0 ")
If E1 = "True" Then Console.Write("X ")
Dim H1 As String = CStr(((dvNames(indexData)("ShiftsSat1"))))
If H1 = "Cook" Then Console.Write("C ")
If H1 = "Front" Then Console.Write("F ")
If H1 = "False" Then Console.Write("0 ")
If H1 = "True" Then Console.Write("X ")
Dim I1 As String = CStr(((dvNames(indexData)("ShiftsSun1"))))
If I1 = "Cook" Then Console.WriteLine("C }")
If I1 = "Front" Then Console.WriteLine("F }")
If I1 = "False" Then Console.WriteLine("0 }")
If I1 = "True" Then Console.WriteLine("X }")
Console.WriteLine("Enter Next Employee Number")

strInput = UCase(Console.ReadLine())

GoTo Alpha

Console.WriteLine(" ")
Console.WriteLine(" ")
Console.WriteLine(" ")
Console.WriteLine(" ")

Console.WriteLine(" ")

Console.WriteLine(" ")
GoTo Beta

End If
strInput = UCase(Console.ReadLine())
End While

End Sub

''' Reads the Products.xml dataset from the embedded resources of the project.
Private Sub CreateDataSet()
Dim thisExe As System.Reflection.Assembly
thisExe = System.Reflection.Assembly.GetExecutingAssembly()
Dim xmlFile As System.IO.Stream
xmlFile = thisExe.GetManifestResourceStream("ConsoleApp.Week6_7.xml")
dvNames = New DataView(dsNames.Tables(0))
dvNames.Sort = "EmployeeNum"
End Sub
End Module

First... You know that this

First... You know that this is about VB6 right? Ur code is VB.NET.. Thats as different as C and C++ ...

But for that what you want to do... Thats easy... You have to use System.Threading.Process
You can open multiple Consoles on different Threads... You can then redirect thier outputs to a main Console for example...

Mybe it helps ->