设有一个命令按钮Command1的事件过程以及一个函数过程。程序如下:Private Sub Command1 Click(  ) Static x A S Integer x=f(x+5) Cls Print XEnd Sub Private Function f(x As Integer)As Integer f=x+xEnd F

2023-04-24

[单选] 设有一个命令按钮Command1的事件过程以及一个函数过程。程序如下:
Private Sub Command1 Click(  )
Static x A S Integer
x=f(x+5)
Cls
Print X
End Sub
Private Function f(x As Integer)As Integer
f=x+x
End Function
连续单击命令按钮3次,第3次单击命令按钮后,窗体显示的计算结果是(  )。

A . 10
B . 30
C . 60
D . 70



参考答案:D

参考解析:

D。【解析】本题考查静态变量,静态变量能将执行后的值储存到变量中。所以当第一次单击按钮
时,x=5,x=f(x+5)=5+5=10,所以x=10,第二次单击按钮时,x=f(x+5)=15+15=30,此时x=30,当第三次单击按钮时,x=f(x+5)=35+35=70,所以答案为D。