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

admin2020-07-25  10

问题 下列程序的输出结果是
    Dim x As Integer
    Private Sub Command4_Click()
    Dim y As Integer
    x=3
    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=3
B、y=10
C、y=13
D、y=7

答案C

解析 在函数参数传递中,包括按地址传递ByRef和按值传递ByVal两种方法。其中前者在函数体内改变变量值会影响参数外的变量,后者不会。本题y是按地址传递,调用fun()函数后,会将Y的值改为fun()函数中V的值,所以应选择选项C。
转载请注明原文地址:https://jikaoti.com/ti/PPQ0FFFM
0

相关试题推荐
最新回复(0)