-
- Byval与Byref的区别
- Weather:4/11度.好冷啊.
- 2004-10-26
实例:
sub Add1(ByVal no as int32)
no=no+100
end subsub Add2(ByRef no as int32)
no=no+100
end subprivate sub button1_click(sender as object,e as eventargs)handles button1.click
dim a as int32
a=100
Add1(a)
msgbox ("a的值为:" & a) '显示:a的值为100Add2(a)
msgbox ("a的值为:" & a) '显示:a的值为200,因为Add2中的参数no为ByRef,即
'按地址传递,因此在Add2中对no进行修改后,将会导致
'源参数a的值也被修改。
End SubByVal是传递值 源数据不会被修改
你可以把这个值当作自己的局部变量来使用ByRef是传递地址 , 源数据可能被修改
你对这个变量的操作将对你传入的那个变量产生影响,就像指针的感觉-
Views(3612) | Comments(0) |
In:
web develop
|
(10/25)
RS.GETROWS使用详解
数据岛(Data Islands)
(10/26)
