Home / Visual Basic Tutorial / Methods and events / Syntax for Calling Method

Syntax for Calling Method

Objectname-Method

Here objectname specifies the name of an object, and Method specifies the name of a method.

Example:

Form1.Print “Hello World”
Here Form1 is form name , and method Print is called to print the String “Hello World” to form.
There are different methods associated with different controls.Methods are useful because they hide the details of how an action is performed.
The programmer just needs to call the method ,how the action is performed it is not his or her headache.

Note That:
Put a dot after the name of control then various options will look like in figure.
Methods associated with some commonly used controls:

List Box
It is control that provides a list of items.

Methods of List Box:

1) Additem: This method adds the specified item to the list
2) Removeitem: This method is used to delete an item from the list.
3) SetFocus: Used to make the list box the Current active element.

Combo Box:
A combo box has all the properties exhibited by the text box and list box.

Methods of combo box:
1.Additem: This method will add the specified item to the combo box.
2.Remove Item: This method will delete an item from the combo box.

Option Button:

Option button are used when the user can select one and only one of the multiple options.
Typically,there are no special methods associated with option buttons.A method associated with option
button is:
Move: Moves a control on the form.

Command Button:

The easiest way to allow the user to interact with an application is to provide a button to click.
Visual Basic provides this in form of Command Button.
One method is used with the command button:
Move: Moves a control on the form