【发布时间】:2011-06-20 01:51:20
【问题描述】:
我的小示例代码
Function AddNr(ByRef x As Integer) As Integer
x = x + 2
AddNr = x
End Function
Sub test()
Dim ana As Integer
ana = 1
AddNr (ana)
MsgBox ana
End Sub
应该输出 3 但输出 1。更具体地说,ana 变量在调用 AddNr 函数后不会被修改。
我的环境是 Excel 2007 中的 Microsoft Visual Basic 6.5。
【问题讨论】:
标签: vba pass-by-reference pass-by-value