有如下Sub过程: Sub Sun(x As Single,y As Single) t=x x=t/y y=t Mod y End Sub 在窗体上的命令按钮Command1中,编写如下事件过程,执行

admin2010-03-30  29

问题 有如下Sub过程:    Sub Sun(x As Single,y As Single)       t=x       x=t/y       y=t Mod y    End Sub    在窗体上的命令按钮Command1中,编写如下事件过程,执行该事件过程调用Sun过程,结果为(    )。    Private Sub Command1_Click()    Dim a As Single    Dim b As Single        a=5        b=4        Sun a,b        Print a;b    End Sub

选项 A、1.25  1
B、5  4
C、4  5
D、1  1.25

答案1

解析 本题考查过程的调用,如果用Call语句调用子过程时,实际参数要放在括号中,如果不使用Call子句,则不必使用括号。本题参数调用时是按地址传递,因此Sun过程中变量的值改变也即改变了单击事件中的a、b变量值。 Sun a,b的执行过程是:t=x=5,x=t/y=1.25,y=t Mod y=1。
转载请注明原文地址:https://kaotiyun.com/show/o41p777K
0

最新回复(0)