Use the method to express the action

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.