1,488
社区成员
发帖
与我相关
我的任务
分享sub Add1(ByVal no as int32)
no=no+100
end sub
sub Add2(ByRef no as int32)
no=no+100
end sub
private sub button1_click(sender as object,e as eventargs)handles button1.click
dim a as int32
a=100
Add1(a)
msgbox ("a的值为:" & a) '显示:a的值为100
Add2(a)
msgbox ("a的值为:" & a) '显示:a的值为200,因为Add2中的参数no为ByRef,即
'按地址传递,因此在Add2中对no进行修改后,将会导致
'源参数a的值也被修改。
End Sub