Ask a simple question: What is ByVal? Don't laugh at me! ~~

zhaozj2021-02-16  74

Reply to: Jervis82 (I am a sponge. Suck. Suck. Suck ...) () Reputation: 100 2004-7-15 13:24:10 Score: 6

Visual Basic scripting edition ??

FUNCTION statement See CALL statement | DIM statement | EXIT statement | NOTHING | SET statement | SUB statement Requirements Requirements The name, parameter, and code of the function of the function of the Function process.

? [Public [default] | private] function name [(?? arglist)] [statements] [name = expression] [exit function] [name = expression] End function parameter PUBLIC indicates that the function of the function can be in all scripts All other procedures are accessed. Default is only used with public keywords in the Class block to indicate that the Function process is the default method of the class. If more than one default process is specified in a class, there is an error. Private means that the function process can only be declared to other procedures in its script or if the function is a data class, then the function can only be accessed by other procedures in this class. Name Function's name, follow the standard variable naming rules. Arglist represents a variable list of parameters to pass to the Function process when calling. Separate multiple variables with commas. The Statements executed in any statement group executed in the body of the function process. EXPRESSION FUNCTION return value. The Arglist parameter contains the following syntax and part:

[Byval | byref] varname [()]

Parameters BYVAL indicates that the parameter is transmitted by value. Byref indicates that the parameter is passed in a reference. VarName represents the name of the parameter variable; following the standard variable naming rules. Note If you do not explicitly specify using public or private, the Function process defaults to public, ie they are visible to all other processes in the script. The value of local variables in function is not retained in the call to the process.

The Function process cannot be defined in any other process (eg, Sub or Property GET).

Use the exit function statement to exit from the Function process. The program continues to perform the statement after the statement to call the function process. An edition exit function statement can appear anywhere in any position of the function process.

Similar to the SUB process, the Function process is an independent process that can get parameters, perform a series of statements and change its parameter values. The difference from the SUB process is: When using the value returned by the function, the function process can be used in the right side of the expression, which is the same as the inner function of the internal function, such as SQR, COS or CHR.

In the expression, the Function process can be called by using a function name and a corresponding parameter list is given by parentheses. See the CALL statement for more information on calling the Function process.

WARNING ?? The function process can be recursive, that is, the process can call itself to complete a given task. However, recursive may cause stack overflow. To return a value from a function, simply assume the value to the function name. An arbitrary position can appear in any location of the process. If no value is assigned to the NAME, the process will return a default value: the value function returns 0, and the string function returns zero length string ("). If there is no object reference in the function to Name (using SET), the function returned to the object will return Nothing.

The following example shows how to return a value to a function named binarysearch. In this case, the FALSE is assigned to the function name, indicating that a certain value is not found.

Function binarysearch (..) ?????... ????? 'Didn't find this value. Returns the false value. ????? if lower> Upper the ????????? binarysearch = false ????????? EXIT FUNCTION ????? End if ?????. .Nd Function variables used in the function process are divided into two categories: one is explicitly declared during the process, and the other is not. The variable (using a DIM or equivalent method) is always a local variable of the process within the process. Variables that are used but not in the process are also local variables unless there are higher levels of location in the process.

Warning ?? Process can use variables that are explicitly declared during the process, but as long as there is any name and the same name of the Script-level definition, name conflicts will be generated. If the undemented variables referenced in the process are the same as other processes, constants, or variables, they will be considered that the process reference is the name of the script level. To avoid such conflicts, use the Option Explicit statement to force explicitly declared variables. WARNING ?? VBScript may rearrange mathematical expressions to increase internal efficiency. When the Function process modifies the value of the variables in the mathematical expression, it should be avoided in the same expression. Require version 1

See CALL statement | DIM statement | EXIT statement | NOTING | SET statement | SUB statement

?

-------------------------------------------------- ------------------------------

© 2001 Microsoft Corporation. All rights reserved.

Reply to: Ziran666 (Natural Sub) () Reputation: 100 2004-7-15 13:24:26 Score: 5

In VB, a copy of the parameter is passed in the way in the VB: BYVAL pass, the BYREF addressing method, the pointer to the parameter is passed.

?

转载请注明原文地址:https://www.9cbs.com/read-16076.html

New Post(0)