窗体中有命令按钮Commandl,事件过程如下: Public Function f(x As Integer)As Integer Dim Y As Integer x=20 Y=2 f=x*Y End F

admin2018-12-22  26

问题 窗体中有命令按钮Commandl,事件过程如下:
    Public Function f(x As Integer)As Integer
    Dim Y As Integer
    x=20
    Y=2
    f=x*Y
    End Function
    Private Sub Commandl_Click()
    Dim Y As Integer
    Static X As Integer
    x=10
    y=5
   y=f(x)
   
    Debug.Print x;Y
    End Sub
    运行程序,单击命令按钮,则立即窗口中显示的内容是

选项 A、10 5
B、10 40
C、20 5
D、20 40

答案B

解析 static为静态变量,要在过程的实例问保留局部变量的值,用此变量,它的持续时间是整个模块执行的时间,但它的有效作用范罔是由其定义位置决定的。
转载请注明原文地址:https://kaotiyun.com/show/1vMp777K
0

最新回复(0)