什么是ByVal,ByRef,ParamArray in Declaration [英] What is ByVal, ByRef, ParamArray in Declaration

查看:98
本文介绍了什么是ByVal,ByRef,ParamArray in Declaration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一些示例代码,声明声明使用 ByVal ByRef ,有时候 ParamArray


任何人都可以告诉我这些3的区别,如果可能的话,用短样本。我已经阅读了Access帮助,但它对我的理解并没有多大帮助,所以我可以使用它。


Yus2Aces

I have seen some sample code with declaration statement using ByVal, ByRef and sometimes ParamArray.

Could anybody enlighten me the difference of these 3 and if possible with the short sample. I''ve read the Access Help, but it doesn''t help me much to understand so I can use it.

Yus2Aces

推荐答案

ByVal用作参数值,其中变量的值将在运行时更改,Byref也用作参数值,但值不会更改,并且paramarray指定过程参数是可选的指定类型的元素数组。 ParamArray只能用于参数列表的最后一个参数。
ByVal is used as a parametre value in which the value of a variable will change at run time and Byref is also used as a param value but the value will not change and paramarray Specifies that a procedure parameter takes an optional array of elements of the specified type. ParamArray can be used only on the last parameter of a parameter list.


Byval和Byref用作一个或多个过程的参数。


设置参数asval它将数据传递给过程/函数。调用函数后该值不会改变。


示例:
Byval and Byref used as parameter for a procedure or functions.

Setting the parameter as byval it will pass data to a procedure/function. The value will not change after the call of the function.

example :
展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


区别在于您是否传递变量/对象的副本,或者是否传递了指向该对象的链接。有时它用于修改变量或返回更多信息然后一个简单的函数将允许,因为一个函数只返回一个值。


想象一下下面的2个子:
The difference lies in whether you pass a copy of the variable/object, or you pass a link to the object. Sometimes its used to modify the variable or return more information then a simple function will allow, as a function returns just one value.

Imagine the 2 following subs:
展开 | 选择 | Wrap | 行号


这篇关于什么是ByVal,ByRef,ParamArray in Declaration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆