设窗体上有一个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
A: 1 2 3
B: 1 3 5
C: 1 3 7
D: 2 4 6
举一反三
- 设有下面程序 Sub inc(a As Integer) Static x As Integer x = x + a Print x; End Sub Private Sub Form_Click() inc 2 inc 3 inc 4 End Sub 程序运行后,单击命令按钮 Command1 ,则输出的结果是________
- 在窗体上画一个命令按钮Command1,编写事件代码如下: Public x As Integer Private Sub Command1_Click() x=3 Call f1 Call f2 MsgBox x End Sub Private Sub f1() x=x*x End Sub Private Sub f2() Dim x As Integer x=x+4 End Sub 运行窗体后,单击命令按钮,则消息框的输出结果为______。
- 在窗体上画一个命令按钮,然后编写如下程序: Private Sub Comrnand3_Click( ) Cop 2 Cop 3 Cop 4 End Sub Sub Cop (a As Integer) Static x As Integer x=x + a Print x; End Sub 程序运行后,单击命令按钮,输出结果为 A: 2 3 4 B: 2 5 9 C: 3 5 4 D: 2 4 3
- 窗体上有标签(Label1、Label2)和命令按钮(Command1),编写如下事件过程: Private x As Integer: Private Sub Command1_Click(): Dim x As Integer, y As Integer: x = 5: y = 3: proc x, y: Label1.Caption = x: Label2.Caption = y: End Sub: Private Sub proc(ByVal a As Integer, b As Integer): x = a + b: b = b * b: End Sub:运行后,单击按钮,Label1和Label2将分别显示
- 在窗体中添加一个名称为Command1的命令按钮,然后编写如下程序: Public x As Integer Private Sub Command1______Click() x=3 Call f1 Call f2 MsgBox x End Sub Private Sub f1() x=x*x End Sub Private Sub f2() Dim x As Integer x=x+4 End Sub 窗体打开运行后,单击命令按钮,则消息框的输出结果为______。