Similarity and difference of process and function in ASP

Source: Internet
Author: User
Tags format define end functions include variable
In VBScript, a procedure or a function is a set of blocks of code that can perform a particular function, and when we define our own processes or functions, we can call them over and over in the script, and the custom procedure or function can be placed in an external folder and invoked using the #include instruction.

In VBScript, a procedure or a function is a set of blocks of code that can perform a particular function, and when we define our own processes or functions, we can call them over and over in the script, and the custom procedure or function can be placed in an external folder and invoked using the #include instruction.

First, the definition:

To define a procedure format:

Sub Procedure Name (variable 1, variable 2, variable N)

For the procedure body, the statements to be executed when the procedure is invoked

End Sub

A Sub procedure is a set of VBScript statements that are contained between a sub and an End Sub statement, performing an action but not returning a value. Sub procedures can use parameters.

Cases:

Sub MySub (a,b) ' defines a sub subroutine with two parameters
Sum=a*b
End Sub

To define a function format:

Function name (parameter 1, parameter 2, parameter n)
Handling content
function name = Process Result
End Function

A Function procedure is a set of VBScript statements that are contained between a function and an End Function statement. A Function procedure is similar to a Sub procedure, but a Function procedure can return a value. A Function procedure returns a value that is assigned to a function name in the statement of a procedure by its name.

For example:

function My_func (a,b)
Dim sum
Sum=a*b
My_func=sum ' Assign value to function name
End Function

Second, call:

The procedure is invoked in a complete way:

Call My_sub (A,B) ' invokes the Sub subroutine using the calls statement.
It is generally simplified to:
My_sub A,b ' calls sub subroutines without using the call statement, which is the most common method.

How the function is invoked:
Sum=my_func (a,b) ' directly refers to the function name for invocation.



Related Article

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.