Methods in VB6

This lesson is about some important and common methods in Visual Basic 6. There is a large number of built-in methods in VB6. This section describes the methods that you'll use most frequently in your program.

What is a method?

A method is a built-in function that works with an object. A method has no meaning without its object. But this is very important to note that a method is not a special thing in VB6 but this is just a function, a block of code, which is associated with an object. The method causes the object to perform a specific task. See the following examples:


The Hide method hides the form Form1 without unloading from memory. So a method performs an action for a particular object.

'In Form1

The Cls method clears the object, generally the form and PictureBox object. In the above code, the method Cls is written without any object. But I said before that it has no meaning without an object. This is because, in this example, Cls means Form1.Cls. 

When you're coding in the form module, you can omit the form name while invoking a form's method. 

In the above code, SetFocus is a method that moves the focus to TextBox. Here also the method causes the object to do something. There are so many methods in Visual Basic.

So now have a look at some of the methods discussed below.


The Print method prints something on the object, generally on form and PictureBox.


Form1.Print "Your text here"
Print "Your text here"

Picture1.print "Your text here"

Here Picture1 is the PictureBox control.


The Move method moves an object.

             Object.Move Left, [Top], [Width], [Height]

Note: The parameters enclosed in square brackets "[ ]" are always optional. Do not type the brackets in your code.


Form1.Move 20, 50, 2000, 2000

Download sample program: Move Example


When vb controls are overlapped, the ZOrder method sets the position of the control. You can position the control in front of or behind other controls. To position the control in front of other controls, simply write the method without any argument. To position it behind other controls, pass 1 as an argument.

Text1.ZOrder 1  'moves it behind other controls
Text1.ZOrder     'moves it to the front


The Cls method clears the form or PictureBox. But it does not mean that it will clear anything on the form or PictureBox. The Cls method clears the contents that are created or drawn by the graphic methods such as Print, Circle etc.

Print "hello"
Picture1.Print "welcome"
Form1.Cls            'or Cls

Here Picture1 is the PictureBox. This program will not print anything as Cls method is executed after printing a text.


The Show method is generally used with multiple forms. It shows an object, a form.



The Refresh method repaints or redraws an object completely. You can immediately update the content of a control using the Refresh method.