在窗体中添加一个名称为Command1的命令按钮,然后编写如下程序: Public x As integer Private Sub Command1_Cliek( ) x=10

admin2010-03-22  30

问题 在窗体中添加一个名称为Command1的命令按钮,然后编写如下程序:          Public x As integer          Private Sub Command1_Cliek( )                   x=10                  Call s1                  Call s2                  MsgBox x            End Sub            Private Sub s1 ( )                  x = x+20            End Sub            Private Sub s2 ( )               Dim x As integer                  x =x +20            End Sub  窗体打开运行后,单击命令按钮,则消息框的输出结果为(    )。

选项 A、10
B、30
C、40
D、50

答案D

解析 由于x为全局变量,故在调用s1、s2两个过程时,x的值发生变化后,仍为全局有效,因此最后x的取值为50。
转载请注明原文地址:https://kaotiyun.com/show/xZwp777K
0

最新回复(0)