概要:
Parameters 指 Sub, Function 定义中的参数。比如下面函数中的 number 就是一个参数。
Public Function ToIncrement(ByVal number As Integer) As Integer
Return number + 1
End Function
而 Arguments 指 Sub, Function 具体调用时的参数值。比如下面代码中 3 就是一个Argument。
x = ToIncrement(3)
In most cases, a procedure must have some information about the circumstances in which it has been called. A procedure that performs repeated or shared tasks uses different information for each call. This information consists of variables, constants, and expressions that you pass to the procedure when you call it.
To communicate this information to the procedure, the procedure defines a parameter, and the calling code passes an argument to that parameter. You can think of the parameter as a parking space and the argument as an automobile. Just as different automobiles can park in a parking space at different times, the calling code can pass a different argument to the same parameter every time that it calls the procedure.
A parameter represents a value that the procedure expects you to pass when you call it. The procedure's declaration defines its parameters.
When you define a Function or Sub procedure, you specify a parameter list in parentheses immediately following the procedure name. For each parameter, you specify a name, a data type, and a passing mechanism (ByVal or ByRef). You can also indicate that a parameter is optional. This means that the calling code does not have to pass a value for it.
The name of each parameter serves as a local variable in the procedure. You use the parameter name the same way you use any other variable.
An argument represents the value that you pass to a procedure parameter when you call the procedure. The calling code supplies the arguments when it calls the procedure.
When you call a Function or Sub procedure, you include an argument list in parentheses immediately following the procedure name. Each argument corresponds to the parameter in the same position in the list.
In contrast to parameter definition, arguments do not have names. Each argument is an expression, which can contain zero or more variables, constants, and literals. The data type of the evaluated expression should typically match the data type defined for the corresponding parameter
上一页: 可修改和不可修改的参数的区别 返回上级目录: VB.NET 的参数传递机制
© 2008 HubaPo.com 版权所有 Contact me