在窗体上画一个名称为Command1的命令按钮和3个名称为Label1、Label2、Label3的标签,然后编写如下程序段: Private x As Integer Private Sub Command1_Click(

admin2013-05-12  35

问题 在窗体上画一个名称为Command1的命令按钮和3个名称为Label1、Label2、Label3的标签,然后编写如下程序段:    Private x As Integer             Private Sub Command1_Click( )                   Static y As Integer                   Dim z As Integer                   n =10                   z = n+z                   y=y+z                   x=x+z                   LabelCaption = x                   LabelCaption = y                   LabelCaption = z            End Sub 运行程序,连续3次单击命令按钮后,则3个标签中显示的内容是(    )。

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

答案4

解析 本题中变量x是用Dim声明的模块级变量,变量Y是用Static声明的过程级变量,而变量z是用Dim声明的过程级变量。第一次单击命令按钮后,3个标签中分别显示10,10,10;第二次单击命令按钮后,3个标签中分别显示20、20、10;第三次单击命令按钮后,3个标签中分别显示30,30,10。答案为C。
转载请注明原文地址:https://jikaoti.com/ti/imV0FFFM
0

最新回复(0)