A method (methods) is an object-related procedure (procedures) that represents the action that an object can perform, compared to a property, which represents the information of an object, and the method is a value that can affect the property. For example, on an analog radio, a user can use the SetVolume method to change the value of a property volume, for example, in vb.net, the ListBox control has a "list" property and can be changed using the clear and add methods.
1. Use a method that requires no parameters
The syntax is as follows:
Object.Method ()
In the following example, the Refresh method can refresh the PictureBox:
Picturebox1.refresh () ' forces a repaint of the control.
Like refresh this method does not require arguments, nor does it return a value.
2. Use a method that requires parameters
First, by separating the arguments with commas, vb.net requires that all the arguments be enclosed in parentheses.
In the following example, the MessageBox.Show method requires a parameter to indicate how the dialog box is displayed and the contents, as follows:
MessageBox.Show ("Database update Complete", "My Application", _
messagebox.ok bitor messagebox.iconexclamation)
3. Use a method of returning a value
Users can use the return value method, which is basically the same as using a function. For example, if you want to get the return value from the MessageBox.Show method and store the return value, just add a variable to the left of the equals sign on the left side of the method:
Intresponse=messagebox.show ("Do your want to exit?", "My Application", _
Messagebox.yesno bitor Messagebox.iconquestion)