下列程序的输出结果是 Dim x As Integer Private Sub Command4_Click() Dim y As Integer x = 1 y = 10 Call fun(y, x) MsgBox "y = " &

admin2020-10-14  23

问题 下列程序的输出结果是
Dim x As Integer
Private Sub Command4_Click()
  Dim y As Integer
  x = 1
  y = 10
  Call fun(y, x)
  MsgBox "y = " & y
End Sub
Sub fun(ByRef y As Integer, ByVal z As Integer)
  y = y + z
  z = y - z
End Sub

选项 A、y = 1
B、y = 10
C、y = 11
D、y = 9

答案C

解析 函数参数包括按地址传递和按值传递两种方法,其中前者在函数体内改变变量值会影响参数外的变量,后者则不会。该题y是地址传递,调用fun()函数时,会改变y的值。因此,本题应选择C选项。
转载请注明原文地址:https://kaotiyun.com/show/Uacp777K
0

最新回复(0)