单选题 VB
题号 #453454

单击一次命令按钮,下列程序代码的执行结果为(  )。
Private Sub Command1_Click()
Dim a As Integer,b As Integer,C As Integer
a=2:b=3:c=4
Print P2(c,b,a)
End Sub
Private Function P l(x As Integer,Y As Integer,Z As Integer)
P1=2*x+Y+3*z
End Function
Private Function P2(x As Integer,Y As Integer,z As Integer)
P2 = P1(z,x,y)+x
End Function

进入在线模考

参考答案

A

答案解析

本题考查了函数的嵌套调用。解答这类题目时,可以用逐级替换的形式来解答。例如解答本题时先从命令按钮的单击事件调用p2函数替换,即将实参abc的值传递给p2中的形参xyz:然后再将p2中的实参xyz值传递给pl中的形参xyz;最后逆行运算调用结果。运算过程为:
Print P2(e,b,a)→Print P2(4,3,2)→Print(Pl(2,4,3)+4)→Print(17+4)→Print 21。

你可能感兴趣的试题

A.Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X As Single,YAs Single) IfButton=2 Then PopupMenu al,2End Sub
B.Private Sub Form_MouseDown(Button As Integer, Shift As Integer,X As Single,Y As Single) PopupMenu al,0Fnd Sub
C.private Sub Form_MouseDown(Button As lnteger,Shift As_Integer,X As Single,Y As Single) PopupMenu a lEndSub
D.Private Sub Form_MouseDown(Button As Integer,Shift As eger,X As Single,YAs Single) If(Button=vbLetfButton)Or(Button=vbRightButton)Then PopupMenu alEndSub
找试题 · 找答案 · 找资料 在线模考