编写如下程序: Private Sub Comrnandl Click0Function proc(i As Integer) Dim m As Integer,n As Integer Dim a As Integer,Static b As Integ

admin2015-11-24  11

问题 编写如下程序:
Private Sub Comrnandl Click0Function proc(i As Integer)
Dim m As Integer,n As Integer Dim a As Integer,Static b As Integer
n=2a:a+1:b=b+1
For m=1 To 3 proc=a.b+i
Printproc(n);End Function
Next in
End Sub
程序运行后,单击命令按钮Command1,输出结果为

选项 A、3 3 3
B、3 4 5
C、3 5 6
D、1 2 3

答案B

解析 使用Dim关键字定义的是动态局部变量,过程执行结束后即被释放;使用Static关键字定义的是静态局部变量,过程执行结束后仍然保留。本题中函数proc中的局部变量a是动态变量,b是静态变量。即每次函数调用后b的值会保留。先后三次调用proc(n)方法,依次输出3、4、5.
转载请注明原文地址:https://kaotiyun.com/show/iRLp777K
0

最新回复(0)