The Cls Method

 

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:

 

frmTest.Cls

or

Me.Cls

 

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