设窗体上有一个Command1命令按钮,还有以下程序代码: Private Sub Command1_Click() Static x As Integer x=x+1 Call proc(x)

admin2015-08-13  16

问题 设窗体上有一个Command1命令按钮,还有以下程序代码:
    Private Sub Command1_Click()
        Static x As Integer
        x=x+1
        Call proc(x)
        Print x,
    End Sub
    Private Sub proc(a As Integer)
        Static x As Integer
        x  =x  +  a
        a  =  x
  End Sub
程序运行后,3次单击命令按钮,则产生的输出是(    )。

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

答案C

解析 注意Static关键字修饰的变量,在过程退出后,变量值保持不变。选C。
转载请注明原文地址:https://kaotiyun.com/show/yvQp777K
0

最新回复(0)