ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






STATEMENT:  Function

Function . . . End Function

The Function statement creates a function, assigns a name, and allows you to list the arguments which are to be passed into the function.

Note the major difference between a function and a subroutine, is that a function can return a value back to where it was called from.

As an option, functions can be declared Private or Public. One option for leaving a Function is to use Exit statements. You can call other functions or subroutines from within a function (nesting). You must end every function with End Function or you will get an error message.

Code:
<% Function aardvark %>
   <% Rem you can place all of the code you desire inside a function %>
<% End Function %>

Code:
<% Private Function aardvark %>
   <% Rem you can place all of the code you desire inside a function %>
<% End Function %>

You can list more than one argument in the function.

Code:
<%
Function aardvark(myvar1, myvar2, mynumber, myarray)
   Rem you can place all of the code you desire inside a function
End Function
%>