The funtion process of vb.net

Source: Internet
Author: User
Tags expression integer

VB.net contains built-in or internal functions, such as MsgBox, CStr, and so on. In addition, you can use function statements to write your own function procedures. The syntax for a Function procedure is:
{private| public| friend|} Function functionname (argument list) [as data type]
Statements
End Function
Like a Sub procedure, a Function procedure is also a separate process that reads a parameter, executes a series of statements, and changes the value of its arguments. Unlike a Sub procedure, a Function procedure can return a value to the calling procedure. There are three differences between a Sub procedure and a Function procedure:
(1) Generally speaking, the right side of the statement or expression contains the Function procedure name and parameter (returnvalue=function), which invokes the function.
(2) The function process has the data type exactly like the variable. This determines the type of return value (if there is no as clause, the default data type is Object).
(3) You can assign a value to functionname, which is the value returned.
When a Function procedure returns a value, the value can become part of the expression. For example, the following is a value that is known to be right-angled to the right triangle and calculates the third side (hypotenuse) function:
Function hypotenuse (A as integer,b as Integer) as String
HYPOTENUSE=MATH.SQRT (a^2+b^2)
End Function
The method that calls a Function procedure in Visual Basic is the same as the method that calls any intrinsic function:
Label1.text=cstr (Hypotenuse (CInt (Text1.Text), CInt (Text2.text)))
Strx=cstr (hypotenuse (width,height))

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.