编写如下程序: Private Sub Command1_Click() Dim x As Integer,y As Integer x=10:y=20 Call fun1(x,y) Print x;y End Sub Private Function f

admin2018-10-18  16

问题 编写如下程序:
Private Sub Command1_Click()
Dim x As Integer,y As Integer
x=10:y=20
Call fun1(x,y)
Print x;y
End Sub
Private Function fun1(ByVal m As Integer,n As Integer)As Integer
m=m*m:n=n+n
End Function
程序运行后,单击命令按钮Command1,输出结果为

选项 A、10 25
B、10 40
C、100 25
D、100 40

答案B

解析 在Visual Basic中调用过程时,参数有两种传递形式:按值传递(Byval)和按址传递(Byref),默认为按址传递。其中,当参数按址传递时,如果在引用该参数的过程中改变了形参的值,同时也就改变了传递参数时实参变量的值。本题中fun1的参数m是按值传递的,n是按地址传递的,因此在fun1中对m的改变不会影响实参x,对n的操作会影响实参y。
转载请注明原文地址:https://kaotiyun.com/show/TPFp777K
0

最新回复(0)